Note that this Wiki is a work in progress, items may not be updated or may disappear entirely as the pages are updated.
Scheduling Multiple Shows Across Multiple Days
From SpacialAudio
The first PAL script will allow you to schedule multiple shows throughout the week. The second PAL script will write the name of the show to your SAMDB so that you can display the name of the show on your website. The third PAL script will schedule jingles, promos, ads, or whatever. I have also included some PHP code that will stop people from requesting music during your shows. I\'m sure there is a way to make this whole process more efficient but it works perfectly for my needs.
These scripts are set up with some assumptions.
1. You have your config set to keep 4 tracks in the queue. 2. You are using either category or weighted rotation.
Of course you can modify the script to suit your needs.
PAL.Loop := True;
var mytime : DateTime = now;
var D: Integer;
var start_time_instrumental, end_time_instrumental : DateTime;
var start_time_contemporary, end_time_contemporary : DateTime;
var start_time_efy, end_time_efy : DateTime;
var start_time_sabbath, end_time_sabbath : DateTime;
{*************************************************************
Set these times to suit your needs. I set my times 15 minutes early because I
keep four tracks in the queue. You could very easily add a Queue.Clear command
and that way your show would start exactly on time. But this works for me.
**************************************************************}
start_time_instrumental := date + EncodeTime(07,45,00,0);
end_time_instrumental := date + EncodeTime(08,45,00,0);
start_time_contemporary := date + EncodeTime(10,45,00,0);
end_time_contemporary := date + EncodeTime(12,45,00,0);
start_time_efy := date + EncodeTime(15,45,00,0);
end_time_efy := date + EncodeTime(16,45,00,0);
start_time_sabbath := date + EncodeTime(19,45,00,0);
end_time_sabbath := date + EncodeTime(20,45,00,0);
if DayOfWeek(Now) = Monday then
begin
if( mytime >= start_time_instrumental) and (mytime <= end_time_instrumental) Then
begin
cat[\'Instrumental\'].QueueBottom(smLemmingLogic,EnforceRules);
PAL.WaitForQueue(5);
end;
if( mytime >= start_time_contemporary) and (mytime <= end_time_contemporary) Then
begin
cat[\'Contemporary\'].QueueBottom(smLemmingLogic,EnforceRules);
PAL.WaitForQueue(5);
end;
if( mytime >= start_time_efy) and (mytime <= end_time_efy) Then
begin
cat[\'EFY\'].QueueBottom(smLemmingLogic,EnforceRules);
PAL.WaitForQueue(5);
end;
if( mytime >= start_time_sabbath) and (mytime <= end_time_sabbath) Then
begin
cat[\'Sunday\'].QueueBottom(smLemmingLogic,EnforceRules);
PAL.WaitForQueue(5);
end;
end;
if DayOfWeek(Now) = Tuesday then
begin
if( mytime >= start_time_instrumental) and (mytime <= end_time_instrumental) Then
begin
cat[\'Instrumental\'].QueueBottom(smLemmingLogic,EnforceRules);
PAL.WaitForQueue(5);
end;
if( mytime >= start_time_efy) and (mytime <= end_time_efy) Then
begin
cat[\'EFY\'].QueueBottom(smLemmingLogic,EnforceRules);
PAL.WaitForQueue(5);
end;
if( mytime >= start_time_sabbath) and (mytime <= end_time_sabbath) Then
begin
cat[\'Sunday\'].QueueBottom(smLemmingLogic,EnforceRules);
PAL.WaitForQueue(5);
end;
end;
if DayOfWeek(Now) = Wednesday then
begin
if( mytime >= start_time_instrumental) and (mytime <= end_time_instrumental) Then
begin
cat[\'Instrumental\'].QueueBottom(smLemmingLogic,EnforceRules);
PAL.WaitForQueue(5);
end;
if( mytime >= start_time_contemporary) and (mytime <= end_time_contemporary) Then
begin
cat[\'Contemporary\'].QueueBottom(smLemmingLogic,EnforceRules);
PAL.WaitForQueue(5);
end;
if( mytime >= start_time_efy) and (mytime <= end_time_efy) Then
begin
cat[\'EFY\'].QueueBottom(smLemmingLogic,EnforceRules);
PAL.WaitForQueue(5);
end;
if( mytime >= start_time_sabbath) and (mytime <= end_time_sabbath) Then
begin
cat[\'Sunday\'].QueueBottom(smLemmingLogic,EnforceRules);
PAL.WaitForQueue(5);
end;
end;
if DayOfWeek(Now) = Thursday then
begin
if( mytime >= start_time_instrumental) and (mytime <= end_time_instrumental) Then
begin
cat[\'Instrumental\'].QueueBottom(smLemmingLogic,EnforceRules);
PAL.WaitForQueue(5);
end;
if( mytime >= start_time_contemporary) and (mytime <= end_time_contemporary) Then
begin
cat[\'Contemporary\'].QueueBottom(smLemmingLogic,EnforceRules);
PAL.WaitForQueue(5);
end;
if( mytime >= start_time_efy) and (mytime <= end_time_efy) Then
begin
cat[\'EFY\'].QueueBottom(smLemmingLogic,EnforceRules);
PAL.WaitForQueue(5);
end;
end;
if DayOfWeek(Now) = Friday then
begin
if( mytime >= start_time_instrumental) and (mytime <= end_time_instrumental) Then
begin
cat[\'Instrumental\'].QueueBottom(smLemmingLogic,EnforceRules);
PAL.WaitForQueue(5);
end;
if( mytime >= start_time_efy) and (mytime <= end_time_efy) Then
begin
cat[\'EFY\'].QueueBottom(smLemmingLogic,EnforceRules);
PAL.WaitForQueue(5);
end;
end;
Now, here is the PAL script that will write to the database so I can display the name of the show on my website. I added a table to the SAMDB called showstatus and then added two fields. The first one is event varchar(255) and the second one is ID char(1). I added the number 1 into this field.
PAL.Loop := True;
var mytime : DateTime = now;
var D: Integer;
var start_time_instrumental, end_time_instrumental, final_starttime_instrumental, final_endtime_instrumental : DateTime;
var start_time_contemporary, end_time_contemporary, final_starttime_contemporary, final_endtime_contemporary : DateTime;
var start_time_efy, end_time_efy, final_starttime_efy, final_endtime_efy : DateTime;
var start_time_sabbath, end_time_sabbath, final_starttime_sabbath, final_endtime_sabbath : DateTime;
start_time_instrumental := date + EncodeTime(07,58,00,0);
end_time_instrumental := date + EncodeTime(07,59,00,0);
final_starttime_instrumental := date + EncodeTime(08,58,00,0);
final_endtime_instrumental := date + EncodeTime(08,59,00,0);
start_time_contemporary := date + EncodeTime(10,58,00,0);
end_time_contemporary := date + EncodeTime(10,59,00,0);
final_starttime_contemporary := date + EncodeTime(12,58,00,0);
final_endtime_contemporary := date + EncodeTime(12,59,00,0);
start_time_efy := date + EncodeTime(15,58,00,0);
end_time_efy := date + EncodeTime(15,59,00,0);
final_starttime_efy := date + EncodeTime(16,58,00,0);
final_endtime_efy := date + EncodeTime(16,59,00,0);
start_time_sabbath := date + EncodeTime(19,58,00,0);
end_time_sabbath := date + EncodeTime(19,59,00,0);
final_starttime_sabbath := date + EncodeTime(20,58,00,0);
final_endtime_sabbath := date + EncodeTime(20,59,00,0);
if DayOfWeek(Now) = Sunday then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"<a href=\\\"http://www.kzion.com/mod.php?mod=calendar&op=list_events&sortby=category&cat_id=2\" target = \\\"_blank\\\">Sunday Broadcast</a>\" WHERE ID = 1\',[]);
WriteLn(\'Simply Instrumental show displayed\');
PAL.WaitForTime(T[\'+24:00:00\']);
end;
if DayOfWeek(Now) = Monday then
begin
if( mytime >= start_time_instrumental) and (mytime <= end_time_instrumental) Then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"<a href=\\\"http://www.kzion.com/mod.php?mod=calendar&op=show_event&event_id=40\\\" target = \\\"_blank\\\">Simply Instrumental</a>\" WHERE ID = 1\',[]);
WriteLn(\'Simply Instrumental show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if (mytime >= final_starttime_instrumental) and (mytime <= final_endtime_instrumental) then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"The KZION Weekly Mix\" WHERE ID = 1\',[]);
WriteLn(\'KZION Mix show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if( mytime >= start_time_contemporary) and (mytime <= end_time_contemporary) Then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"<a href=\\\"http://www.kzion.com/mod.php?mod=calendar&op=show_event&event_id=42\\\" target = \\\"_blank\\\">Contemporary Madness</a>\" WHERE ID = 1\',[]);
WriteLn(\'Contemporary Madness show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if (mytime >= final_starttime_contemporary) and (mytime <= final_endtime_contemporary) then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"The KZION Weekly Mix\" WHERE ID = 1\',[]);
WriteLn(\'KZION Mix show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if( mytime >= start_time_efy) and (mytime <= end_time_efy) Then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"<a href=\\\"http://www.kzion.com/mod.php?mod=calendar&op=show_event&event_id=43\\\" target = \\\"_blank\\\">The Best of EFY</a>\" WHERE ID = 1\',[]);
WriteLn(\'Simply EFY show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if (mytime >= final_starttime_efy) and (mytime <= final_endtime_efy) then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"The KZION Weekly Mix\" WHERE ID = 1\',[]);
WriteLn(\'KZION Mix show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if( mytime >= start_time_sabbath) and (mytime <= end_time_sabbath) Then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"<a href=\\\"http://www.kzion.com/mod.php?mod=calendar&op=show_event&event_id=44\\\" target = \\\"_blank\\\">The Sabbath Hour</a>\" WHERE ID = 1\',[]);
WriteLn(\'The Sabbath Hour show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if (mytime >= final_starttime_sabbath) and (mytime <= final_endtime_sabbath) then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"The KZION Weekly Mix\" WHERE ID = 1\',[]);
WriteLn(\'KZION Mix show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
end;
if DayOfWeek(Now) = Tuesday then
begin
if( mytime >= start_time_instrumental) and (mytime <= end_time_instrumental) Then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"<a href=\\\"http://www.kzion.com/mod.php?mod=calendar&op=show_event&event_id=40\\\" target = \\\"_blank\\\">Simply Instrumental</a>\" WHERE ID = 1\',[]);
WriteLn(\'Simply Instrumental show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if (mytime >= final_starttime_instrumental) and (mytime <= final_endtime_instrumental) then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"The KZION Weekly Mix\" WHERE ID = 1\',[]);
WriteLn(\'KZION Mix show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if( mytime >= start_time_efy) and (mytime <= end_time_efy) Then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"<a href=\\\"http://www.kzion.com/mod.php?mod=calendar&op=show_event&event_id=43\\\" target = \\\"_blank\\\">The Best of EFY</a>\" WHERE ID = 1\',[]);
WriteLn(\'Simply EFY show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if (mytime >= final_starttime_efy) and (mytime <= final_endtime_efy) then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"The KZION Weekly Mix\" WHERE ID = 1\',[]);
WriteLn(\'KZION Mix show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if( mytime >= start_time_sabbath) and (mytime <= end_time_sabbath) Then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"<a href=\\\"http://www.kzion.com/mod.php?mod=calendar&op=show_event&event_id=44\\\" target = \\\"_blank\\\">The Sabbath Hour</a>\" WHERE ID = 1\',[]);
WriteLn(\'The Sabbath Hour show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if (mytime >= final_starttime_sabbath) and (mytime <= final_endtime_sabbath) then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"The KZION Weekly Mix\" WHERE ID = 1\',[]);
WriteLn(\'KZION Mix show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
end;
if DayOfWeek(Now) = Wednesday then
begin
if( mytime >= start_time_instrumental) and (mytime <= end_time_instrumental) Then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"<a href=\\\"http://www.kzion.com/mod.php?mod=calendar&op=show_event&event_id=40\\\" target = \\\"_blank\\\">Simply Instrumental</a>\" WHERE ID = 1\',[]);
WriteLn(\'Simply Instrumental show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if (mytime >= final_starttime_instrumental) and (mytime <= final_endtime_instrumental) then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"The KZION Weekly Mix\" WHERE ID = 1\',[]);
WriteLn(\'KZION Mix show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if( mytime >= start_time_contemporary) and (mytime <= end_time_contemporary) Then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"<a href=\\\"http://www.kzion.com/mod.php?mod=calendar&op=show_event&event_id=42\\\" target = \\\"_blank\\\">Contemporary Madness</a>\" WHERE ID = 1\',[]);
WriteLn(\'Contemporary Madness show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if (mytime >= final_starttime_contemporary) and (mytime <= final_endtime_contemporary) then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"The KZION Weekly Mix\" WHERE ID = 1\',[]);
WriteLn(\'KZION Mix show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if( mytime >= start_time_efy) and (mytime <= end_time_efy) Then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"<a href=\\\"http://www.kzion.com/mod.php?mod=calendar&op=show_event&event_id=43\\\" target = \\\"_blank\\\">The Best of EFY</a>\" WHERE ID = 1\',[]);
WriteLn(\'Simply EFY show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if (mytime >= final_starttime_efy) and (mytime <= final_endtime_efy) then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"The KZION Weekly Mix\" WHERE ID = 1\',[]);
WriteLn(\'KZION Mix show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if( mytime >= start_time_sabbath) and (mytime <= end_time_sabbath) Then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"<a href=\\\"http://www.kzion.com/mod.php?mod=calendar&op=show_event&event_id=44\\\" target = \\\"_blank\\\">The Sabbath Hour</a>\" WHERE ID = 1\',[]);
WriteLn(\'The Sabbath Hour show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if (mytime >= final_starttime_sabbath) and (mytime <= final_endtime_sabbath) then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"The KZION Weekly Mix\" WHERE ID = 1\',[]);
WriteLn(\'KZION Mix show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
end;
if DayOfWeek(Now) = Thursday then
begin
if( mytime >= start_time_instrumental) and (mytime <= end_time_instrumental) Then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"<a href=\\\"http://www.kzion.com/mod.php?mod=calendar&op=show_event&event_id=40\\\" target = \\\"_blank\\\">Simply Instrumental</a>\" WHERE ID = 1\',[]);
WriteLn(\'Simply Instrumental show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if (mytime >= final_starttime_instrumental) and (mytime <= final_endtime_instrumental) then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"The KZION Weekly Mix\" WHERE ID = 1\',[]);
WriteLn(\'KZION Mix show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if( mytime >= start_time_contemporary) and (mytime <= end_time_contemporary) Then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"<a href=\\\"http://www.kzion.com/mod.php?mod=calendar&op=show_event&event_id=42\\\" target = \\\"_blank\\\">Contemporary Madness</a>\" WHERE ID = 1\',[]);
WriteLn(\'Contemporary Madness show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if (mytime >= final_starttime_contemporary) and (mytime <= final_endtime_contemporary) then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"The KZION Weekly Mix\" WHERE ID = 1\',[]);
WriteLn(\'KZION Mix show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if( mytime >= start_time_efy) and (mytime <= end_time_efy) Then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"<a href=\\\"http://www.kzion.com/mod.php?mod=calendar&op=show_event&event_id=43\\\" target = \\\"_blank\\\">The Best of EFY</a>\" WHERE ID = 1\',[]);
WriteLn(\'Simply EFY show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if (mytime >= final_starttime_efy) and (mytime <= final_endtime_efy) then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"The KZION Weekly Mix\" WHERE ID = 1\',[]);
WriteLn(\'KZION Mix show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
end;
if DayOfWeek(Now) = Friday then
begin
if( mytime >= start_time_instrumental) and (mytime <= end_time_instrumental) Then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"<a href=\\\"http://www.kzion.com/mod.php?mod=calendar&op=show_event&event_id=40\\\" target = \\\"_blank\\\">Simply Instrumental</a>\" WHERE ID = 1\',[]);
WriteLn(\'Simply Instrumental show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if (mytime >= final_starttime_instrumental) and (mytime <= final_endtime_instrumental) then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"The KZION Weekly Mix\" WHERE ID = 1\',[]);
WriteLn(\'KZION Mix show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if( mytime >= start_time_efy) and (mytime <= end_time_efy) Then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"<a href=\\\"http://www.kzion.com/mod.php?mod=calendar&op=show_event&event_id=43\\\" target = \\\"_blank\\\">The Best of EFY</a>\" WHERE ID = 1\',[]);
WriteLn(\'Simply EFY show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
if (mytime >= final_starttime_efy) and (mytime <= final_endtime_efy) then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"The KZION Weekly Mix\" WHERE ID = 1\',[]);
WriteLn(\'KZION Mix show displayed\');
PAL.WaitForTime(T[\'+00:02:00\']);
end;
end;
if DayOfWeek(Now) = Saturday then
begin
D:=ExecSQL(\'UPDATE showstatus SET event = \"The KZION Weekly Mix\" WHERE ID = 1\',[]);
WriteLn(\'The KZION Weekly Mix displayed\');
PAL.WaitForTime(T[\'+22:00:00\']);
end;
Here is the PAL script that runs my jingles.
PAL.Loop := True;
var mytime : string;
mytime := timetostr(Now);
PAL.WaitForPlayCount(8);
cat['Station IDs (All)'].QueueBottom(smLRP,NoRules);
PAL.WaitForPlayCount(6);
cat['Jingles (All)'].QueueBottom(smRandom,NoRules);
PAL.WaitForPlayCount(8);
cat['Jingles (All)'].QueueBottom(smRandom,NoRules);
PAL.WaitForPlayCount(6);
cat['Promos (All)'].QueueBottom(smLRP,NoRules);
cat['Jingles (All)'].QueueBottom(smRandom,NoRules);
Here is what I add to my req.php file (at the very top) so that people cannot request music during my show.
<?
require_once(\"/sam2/config.php\");
$db->open(\"SELECT event FROM showstatus where ID = \'1\'\");
$historys = $db->rows();
list($key, $songs) = each($historys);
$event = $songs[\"event\"];
if ($event != \"The KZION Weekly Mix\") {
echo (\"<html><head><title>Checking Request Status</title>\");
echo (\"<link rel=stylesheet type=text/css href=http://www.kzion.com/styles/main.css></head><body bgcolor=#686800>\");
echo (\"| \");
echo (\" I\'m sorry, but we\'re not able to take your request right now. KZION is currently broadcasting $event. Please check the KZION calendar to see when the $event will end. You\'re welcome to request anytime except during a show or Special Broadcast. Also, to ensure a day of Sabbath appropriate music we do not process any requests on Sunday. Thank you for listening. <a href=javascript:window.close();>Close This Window</a>\"); echo (\"</td></tr></table></body></html>\");
EXIT;
} else {
and then add the rest of your req.php code here...
|
