Note that this Wiki is a work in progress, items may not be updated or may disappear entirely as the pages are updated.

SAM request/playlist policies via database

From SpacialAudio

Jump to: navigation, search

If you'd like to use SAM's request/playlist values in your website (php for sure, html not supported by me), check out:

My PALs (http://www.festerhead.com/samweb/pals.php) -> policies.pal

For requests, we have: Enabled InsertPos ArtistRule SongRule DelayTime Limit LimitInterval DailyLimit

For playlists, we have: MinArtistTime MinQueueSize MinSongTime UseGhostQueue


If you change these values in another PAL, then you can now update the database and use the new values on your website.

Enjoy.

You may download the script here. http://spacialnet.com/knowledge/attachment.php?attId=76 (retrieved via archive.org)

// Don't be a dick.  Leave this here.
// Policies Setup/Rest script by FesterHead (pal@festerhead.com)
// Version 1.0 11/29/2003
//
// Updates/Adds SAMs playlist/request policies to the database
//
// To use in other PALs, make sure to run this script at least once.
// Then, simply use an update SQL call via ExecSQL (see below for syntax)
// Make sure to change Booleans
//   0 (zero = false) or not 0 (anything not zero = true)
//
// See below for changelog
//
// For support, visit http://www.festerhead.com/forums/viewforum.php?f=6
//
// If you find my PALs useful, please consider donating for the time/effort/support
// http://www.festerhead.com/forums/viewtopic.php?t=123
//
// Mahalo for your kokua
//
// WARNING!
// IF YOU DON'T CONFIGURE THE SCRIPT, DON'T EXPECT IT TO WORK PROPERLY!
// I built this PAL for my station using my station configuration
// Your results and mileage may vary
//
// I suggest running the PAL in debugOn mode for a couple days to see if it needs tweaking

// Make the PAL run fast!
PAL.LockExecution;

// **************************
// * START OF CONFIGURABLES *
// **************************

// Run in debug mode?
// This will write to the screen or history table(s) without any queue interaction
// Useful for testing the script settings
// We still do the waiting if this is true to simulate an actual run
// Turns on memory leak warning
// Default is false
var debugOn : Boolean = false;

// Turn memory leak warning on even when debugOn is false?
// Default is false
var memoryLeakAlwaysOn : Boolean = false;

// Is this cool or what?
// Default is true
// var cool : Boolean = true;

// ************************
// * END OF CONFIGURABLES *
// ************************

// IF YOU EDIT BELOW HERE, MAKE DARN SURE YOU KNOW WHAT'S GOING ON

// Declare variables
var policyCount : TDataSet;

// Declare/Initialize variables
var req_Enabled : Integer = 0;
if (RequestPolicy.Enabled) then
  begin
    req_Enabled := 1;
  end;
  
var req_ArtistRule : Integer = 0;
if (RequestPolicy.ArtistRule) then
  begin
    req_ArtistRule := 1;
  end;
  
var req_SongRule : Integer = 0;  
if (RequestPolicy.SongRule) then
  begin
    req_SongRule := 1;
  end;
  
var play_UseGhostQueue : Integer = 0;
if (PlaylistRules.UseGhostQueue) then
  begin
    play_UseGhostQueue := 1;
  end;

if (debugOn or memoryLeakAlwaysOn) then
  begin
    PAL.MemoryLeakWarning := true;
    WriteLn('Memory leak warning is ON');
  end;


// Create the table if it doesn't already exist
ExecSQL('CREATE TABLE IF NOT EXISTS policies ' +
        '(req_Enabled mediumint(9) NOT NULL default ''0'', ' +
         'req_InsertPos mediumint(9) NOT NULL default ''0'', ' +
         'req_ArtistRule mediumint(9) NOT NULL default ''0'', ' +
         'req_SongRule mediumint(9) NOT NULL default ''0'', ' +
         'req_DelayTime mediumint(9) NOT NULL default ''0'', ' +
         'req_Limit mediumint(9) NOT NULL default ''0'', ' +
         'req_LimitInterval mediumint(9) NOT NULL default ''0'', ' +
         'req_DailyLimit mediumint(9) NOT NULL default ''0'', ' +
         'play_MinArtistTime mediumint(9) NOT NULL default ''0'', ' +
         'play_MinQueueSize mediumint(9) NOT NULL default ''0'', ' +
         'play_MinSongTime mediumint(9) NOT NULL default ''0'', ' +
         'play_UseGhostQueue mediumint(9) NOT NULL default ''0'')', []);

policyCount := Query('SELECT COUNT(*) AS cnt FROM policies', [], true);

// If no rows in policies, do an insert
// Else, do an update
if (policyCount['cnt'] = 0) then
  begin
    ExecSQL('INSERT INTO policies (req_Enabled, req_InsertPos, ' +
                                  'req_ArtistRule, req_SongRule, ' +
                                  'req_DelayTime, req_Limit, ' +
                                  'req_LimitInterval, req_DailyLimit, ' +
                                  'play_MinArtistTime, play_MinQueueSize, ' +
                                  'play_MinSongTime, play_UseGhostQueue) ' +
            'VALUES (' + IntToStr(req_Enabled) + ', ' + IntToStr(RequestPolicy.InsertPos) + ', ' +
                         IntToStr(req_ArtistRule) + ', ' + IntToStr(req_SongRule) + ', ' +
                         IntToStr(RequestPolicy.DelayTime) + ', ' + IntToStr(RequestPolicy.Limit) + ', ' +
                         IntToStr(RequestPolicy.LimitInterval) + ', ' + IntToStr(RequestPolicy.DailyLimit) + ', ' +
                         IntToStr(PlaylistRules.MinArtistTime) + ', ' + IntToStr(PlaylistRules.MinSongTime) + ', ' +
                         IntToStr(PlaylistRules.MinSongTime) + ', ' + IntToStr(play_UseGhostQueue) + ')', []);
  end
else
  begin
    ExecSQL('UPDATE policies SET req_Enabled = ' + IntToStr(req_Enabled), []);
    ExecSQL('UPDATE policies SET req_InsertPos = ' + IntToStr(RequestPolicy.InsertPos), []);
    ExecSQL('UPDATE policies SET req_ArtistRule = ' + IntToStr(req_ArtistRule), []);
    ExecSQL('UPDATE policies SET req_SongRule = ' + IntToStr(req_SongRule), []);
    ExecSQL('UPDATE policies SET req_DelayTime = ' + IntToStr(RequestPolicy.DelayTime), []);
    ExecSQL('UPDATE policies SET req_Limit = ' + IntToStr(RequestPolicy.Limit), []);
    ExecSQL('UPDATE policies SET req_LimitInterval = ' + IntToStr(RequestPolicy.LimitInterval), []);
    ExecSQL('UPDATE policies SET req_DailyLimit = ' + IntToStr(RequestPolicy.DailyLimit), []);
    ExecSQL('UPDATE policies SET play_MinArtistTime = ' + IntToStr(PlaylistRules.MinArtistTime), []);
    ExecSQL('UPDATE policies SET play_MinQueueSize = ' + IntToStr(PlaylistRules.MinQueueSize), []);
    ExecSQL('UPDATE policies SET play_MinSongTime = ' + IntToStr(PlaylistRules.MinSongTime), []);
    ExecSQL('UPDATE policies SET play_UseGhostQueue = ' + IntToStr(play_UseGhostQueue), []);
  end;


PAL.UnlockExecution;

policyCount.Free;

// *************
// * Changelog *
// *************
//
// 1.0
// * Initial PAL

Personal tools