Skip to Content
It is currently April 22nd, 2021, 8:15 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: February 6th, 2012, 7:14 am 
Offline
New User
New User

Joined: November 11th, 2006, 2:00 pm
Posts: 3
Hi.
I apologize for any mistakes but English is not my native language.
If someone can help me. I need 3 PAL scripts

1. Script must play on AUX 1/2 a jingle/drop/etc when the current track on DECK A/B is played for the first time.
I guess it look like this:
Code:
PAL.Loop := True;
PAL.WaitForPlayCount(1);
PAL.WaitForTime('+00:00:05');

// The number must be 1, the track is currently playing
if played_count is 1 then
begin
//play in aux 1/2 (I know this part)
end
else begin ;
//do nothing
end;


2. I want to display on a webpage the number of listeners in real time. I have multiple encoders (icecast & shoutcast).
Can PAL generate/write to a file (html, php, txt) $viewers$ every let's say 30 seconds? I know is not real time but is better than at track change.
It might be another way: PAL trigger "generate" button/function. Is this possibile?
Code:
PAL.Loop := True;
PAL.WaitForTime('+00:00:30');
generate a page with $viewers$


3. If track lenght is greater than 45 minutes do something. I will use with the second script needed.
Code:
if track lenght is > 45 mins then
begin
//do something
end
else begin ;
//do nothing
end;


I searched the forum but I did not found a topic on this subject.
Thank you in advance.


Top
 Profile  
Reply with quote  
PostPosted: February 6th, 2012, 10:50 pm 
Offline
New User
New User

Joined: March 21st, 2008, 7:11 am
Posts: 10
Location: sacramento, california
I use the following PAL script to do my "up-to-date" listener totals. The script also keeps track of Peak listener counts as well. It's probably not the best way to do things, but back in 08 when I originally wrote the script, it was all I could figure out for the listener count issue.

The script requires a MySQL DB to write the information to, but I'm sure with a little hackery you can remove the SQL stuff, and have it write the output to a page.

Code:
{===============================================================================
Listener Counts and Statistics PAL script
-  listener_counts.pal
-  last edit on 4.13.2008   @  00:04 PST

--created by Aaron Cupp (disfigure aka MrCupp) @ Tech-Noid Systems

Overview:
  This script will keep track of your listsner counts.
  The script fires once a minute and counts the listeners on all your relays
  The script uses 2 database tables to keep the information.
  --  if you do not have these tables in you database, they will be created.
   1.  relay_counts  :  This table hold the overall listener counts.
                        This table does not clear itself out.
                        Great for user stats.
   2.  am_relays  :  This table holds information about each relay
                     The relays are the ones listed in the Statistic Relays area.
                     This table clears itself on each loop
===============================================================================}
{ testing and debug mode...enables memory leak warning by default }
var debugOn : Boolean = true;

{===============================================================================
Create the table if it doesn't already exist
---  this is the table that holds the total listener counts
===============================================================================}
ExecSQL('CREATE TABLE IF NOT EXISTS relay_counts ' +
       '(id MEDIUMINT(9)NOT NULL AUTO_INCREMENT KEY, ' +
       'viewers MEDIUMINT(9) DEFAULT 0, date TEXT(255))', []);
{===============================================================================
Create the table if it doesn't already exist
---  this is the table that holds the info for each of the listener relays
===============================================================================}
ExecSQL('CREATE TABLE IF NOT EXISTS sam_relays ' +
       '(id MEDIUMINT(9), status TEXT(255), viewers MEDIUMINT(9), ' +
       'viewers_high MEDIUMINT(9), details TEXT(255), bitrate MEDIUMINT(9), ' +
       'stream_format TEXT(255))', []);
{===============================================================================
Create the table if it doesn't already exist
---  this is the table that holds the info for the peak listener counts
===============================================================================}
ExecSQL('CREATE TABLE IF NOT EXISTS listener_peak ' +
       '(id MEDIUMINT(9)NOT NULL AUTO_INCREMENT KEY, ' +
       'listeners MEDIUMINT(9) DEFAULT 0, artist TEXT(255), ' +
       'title TEXT(255), date_played TEXT(255))', []);

{ Time to Loop }      
PAL.LOOP := True;      
{===============================================================================
declare our varibale that are used in this script.
  we can set these to some inital values
===============================================================================}
var I : Integer;
var S : TDataSet;

var nowplaying, cCount, oCount : TDataSet;
var curCount, oldCount : Integer;
var curArtist, curTitle, curTime : String;

var mytime : DateTime = now;
var relayCount : Integer = 0;
var totalCount : Integer = 0;
{===============================================================================
let us count the listerns we have on all relays.
---  use this information to show total listeners on your webpage or in IRC
===============================================================================}
PAL.LockExecution;
  for I := 0 to Relays.Count-1 do
    begin
      relayCount := Relays[I].Viewers;
      totalCount := totalCount + relayCount;
      curTime := DateTimeToStr(mytime);
    end;
    totalCount := totalCount;
    WriteLn('Updating the listener count table');
    ExecSQL('INSERT INTO relay_counts (viewers,date) VALUES (' + IntToStr(totalCount) + ', ' + QuotedStr(curTime) + ')',[]);
PAL.UnlockExecution;
{===============================================================================
time to do the relays by themselves
---  data can be used to make a nice servers screen on your webpage
---  use this data for relay info as well
===============================================================================}
PAL.LockExecution;
  for I := 0 to Relays.Count-1 do
    begin
      WriteLn('Updating the relay server db - all the infoz ');
      Execsql('INSERT INTO sam_relays VALUES (' + IntToStr(I) + ', ' + QuotedStr(Relays[I].Status) + ', ' + IntToStr(Relays[I].Viewers) + ', ' + IntToStr(Relays[I].Viewers_High) + ', ' + QuotedStr(Relays[I].Details) + ', ' + IntToStr(Relays[I].Bitrate) + ', ' + QuotedStr(Relays[I].Format) + ')',[]);
    end;
PAL.UnlockExecution;
{===============================================================================
lets calculate the peak listener count
---  use this information to show total listeners on your webpage or in IRC
===============================================================================}
PAL.LockExecution;
  nowplaying := Query('SELECT songlist.artist, songlist.title, historylist.date_played FROM historylist,songlist WHERE (historylist.songID = songlist.ID) AND (songlist.songtype="S" OR songlist.songtype="J") ORDER BY historylist.date_played DESC LIMIT 1', [], true);
  cCount := Query('SELECT viewers FROM relay_counts ORDER BY id DESC LIMIT 1', [], true);
  oCount := Query('SELECT listeners FROM listener_peak ORDER BY listeners DESC LIMIT 1', [], true);

  { put the data into usefull containers }
  curCount := StrToInt(cCount['viewers']);
  oldCount := StrToInt(oCount['listeners']);
  curArtist := nowplaying['artist'];
  curTitle := nowplaying['title'];
  curTime := DateTimeToStr(mytime);

  WriteLn( curCount );
  WriteLn( oldCount );
  WriteLn( curArtist );
  WriteLn( curTitle );
  WriteLn( curTime );

  if (curCount > oldCount) then
    begin
      WriteLn('NEW PEAK!! Time to update the peak count');
      ExecSQL('INSERT INTO listener_peak (listeners,artist,title,date_played) VALUES (' + IntToStr(curCount) + ', ' + QuotedStr(curArtist) + ', ' + QuotedStr(curTitle) + ', ' + QuotedStr(curTime) + ')',[]);
    end;
PAL.UnlockExecution;

{ clean up the created data sets }
S.Free;
nowplaying.Free;
cCount.Free;
oCount.Free;
{===============================================================================
Wait for 1 minute to update table
===============================================================================}
PAL.WaitForTime('+00:01:00');
{===============================================================================
Clear the table on each loop
---  we clear out the relay table every loop to keep it tidy
===============================================================================}
Execsql('TRUNCATE sam_relays',[]);

_________________
--------

MrCupp aka disfigure
Tech-Noid Systems - Music on Another Level
MrCupp.com - All Things MrCupp Related


Top
 Profile  
Reply with quote  
PostPosted: February 7th, 2012, 4:07 am 
Offline
New User
New User

Joined: November 11th, 2006, 2:00 pm
Posts: 3
Good idea. It's easier to take data from MySQL and post them on the webpage, including peak.
Thank you very much.

Let's see if someone comes up with an idea for script 1 and 3.


Top
 Profile  
Reply with quote  
PostPosted: March 23rd, 2012, 8:53 am 
Offline
New User
New User

Joined: March 23rd, 2012, 8:48 am
Posts: 2
Please help with a script that would be the end of the track to be displayed listeners. For example:
Tom feat. Lee - Where Do You Go (Club Radio Edit) / / Listens: 154
I want to, because that would be displayed to users.
Sorry for my english, I'm from Russia


Top
 Profile  
Reply with quote  
PostPosted: March 23rd, 2012, 4:15 pm 
Offline
New User
New User

Joined: March 23rd, 2012, 8:48 am
Posts: 2
All thanks, already made

Code:
PAL.Loop := True;
var Listeners: integer;
var Song : TSongInfo;
var CurSong : TSongInfo;

CurSong := ActivePlayer.GetSongInfo;
Song := TSongInfo.Create ;
Listeners := Relays.Viewers;

Song['artist'] := CurSong['Artist'];
Song['title']  := CurSong['Title'] + '  [' + 'Listen:' + IntToStr(Listeners) + ']';

  Encoders.SongChange(Song);
Song.Free;
PAL.WaitForTime('+00:00:15');


Top
 Profile  
Reply with quote  
PostPosted: June 28th, 2012, 4:39 am 
Offline
New User
New User

Joined: November 11th, 2006, 2:00 pm
Posts: 3
I need a script to play a jingle/drop/etc only if the current track is played for the first time.
I guess it must have the database field "played_count" = 1 (current play).

Code:
PAL.Loop := True;
PAL.WaitForPlayCount(1);
PAL.WaitForTime('+00:00:05');

// If the track currently is played for the first time (aka New Entry)
if played_count is 1 then
begin
//play in aux 1/2 (I know this part)
end
else begin ;
//do nothing
end;


Many thanks in advance.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 25 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group