Note that this Wiki is a work in progress, items may not be updated or may disappear entirely as the pages are updated.
Two-For-Tuesday PAL script
From SpacialAudio
The following is a Two-For-Tuesday PAL Script. Simply copy and paste the full code below.
Don't be a dick. Leave this here. Two-For-Tuesday script by FesterHead (fester@festerhead.com) Version 1.1 04/22/2003
1.1 changes
- Wrapped strings with QuotedStr() to prevent script stoppage when selecting artist/album with single quote ( ' ) character
- Replaced PAL.WaitForCount(2) with PAL.WaitForQueue(4) to prevent queue from filling up with songs. This happens if there are are other regularly scheduled jingles, ads, and/or what-nots.
Plays back-to-back artists all day Tuesday
PAL.Loop := True;
//Only run on Tuesday
if DayOfWeek(Now) = Tuesday then
begin
// Declare variables
var theArtistInQueue, theCountSongs, theSongChooser : TDataSet;
WriteLn('Starting Two-For-Tuesday PAL script...');
WriteLn();
// Choose a random song while enforcing the rules and put in queue bottom
CAT['Songs'].QueueBottom(smRandom,EnforceRules);
// Let's find out the artist and songid we just put in the queue
theArtistInQueue := Query('select title, artist, songID, queuelist.id as queueID ' +
'from songlist, queuelist ' +
'where songlist.id = queuelist.songID '+
'order by queueID desc limit 1',[],True);
WriteLn('Added: ' + QuotedStr(theArtistInQueue['artist']));
WriteLn(' ' + QuotedStr(theArtistInQueue['title']));
WriteLn();
// Let's get a count of the remaining songs by this artist
theCountSongs := Query('select count(*) as cnt' +
' from songlist' +
' where id <> ' + IntToStr(theArtistInQueue['songID']) +
' and songtype = S' +
' and artist = ' + QuotedStr(theArtistInQueue['artist']),[],True);
WriteLn('There are ' + IntToStr(theCountSongs['cnt']) + ' songs to choose from');
WriteLn();
if (theCountSongs['cnt'] = 0) then
begin
WriteLn('ZERO songs to choose from!');
WriteLn('Removing ' + QuotedStr(theArtistInQueue['artist']));
Queue.Delete(StrToInt(theArtistInQueue['queueID']));
WriteLn('Starting over...');
end
else
begin
WriteLn('Choosing random song...');
// Choose a random song from the remaining songs by this artist
theSongChooser := Query('select title, filename' +
' from songlist' +
' where id <> ' + IntToStr(theArtistInQueue['songID']) +
' and songtype = S' +
' and artist = ' + QuotedStr(theArtistInQueue['artist']) +
' order by rand() limit 1',[],True);
// Put random song in queue bottom
Queue.AddFile(theSongChooser['filename'],ipBottom);
WriteLn('Added: ' + QuotedStr(theArtistInQueue['artist']));
WriteLn(' ' + QuotedStr(theSongChooser['title']));
WriteLn();
// Be nice... Free up the data structures
theSongChooser.Free;
theArtistInQueue.Free;
theCountSongs.Free;
//Wait for queue to contain 4 tracks before continuing
WriteLn('Waiting for queue to contain 4 tracks before continuing...');
PAL.WaitForQueue(4);
end;
end;
