Skip to Content
It is currently November 20th, 2019, 6:46 am

All times are UTC - 6 hours [ DST ]

Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: May 19th, 2018, 6:14 pm 
New User
New User

Joined: May 19th, 2018, 5:34 pm
Posts: 1
I saw more people requesting such a script but I did not find a solution, so I wrote a script myself. I am not an expert when it comes to PAL scripting, so I used code from another topic in this forum.

This script will seperate the artists when there are 2 or more artists singing a song and update the field date_artist_played in the MySQL database for every artist.

Let me explain this with an example: Sam Broadcaster sees "Michael Jackson" And "Michael Jackson & Paul McCartney" as 2 different artists. So no matter how much time you have entered in the "Do not play same artist within XX minutes" field under the playlist rotation rules, Sam can play a song of "Michael Jackson" and a song of "Michael Jackson & Paul McCartney" next to each other. This is not what you want.

When SB plays "Michael Jackson - Thriller" the program will update the field date_artist_played for all Michael Jackson songs which were sang by him alone. This script will also find the songs Michael sang with other artists like "Michael Jackson & Paul McCartney" , "Stevie Wonder & Michael Jackson" , "Michael Jackson & The Jackson 5" , "Wiz Stars & Michael Jackson & Diana Ross" etc and update the records in the database

What is very important for this script to work properly is that you have all the songs correctly spelled with the same delimiter. It is only possible to specify one delimiter, in the examples above it's always the '&' character, but if you have 'ft' or 'AND' or ',' or '+' you can specify it in the script and (I guess) it will work.

I have not tested everything. And since I am not an expert I don't know if I can help with all problems you run into. So help from other members of the board is appreciated.

Needles to say, you run the script at your own risc so please, always have a backup before running this! And I guess its only functional on a MySQL database.

This is the code:
PAL.Loop := True;

var Song : TSongInfo;

PAL.WaitForTime(T['+00:00:05']); // To prevent the script runs to often when no item of the S songtype is played

Song := ActivePlayer.GetSongInfo;

if Song = nil then
   WriteLn('No Song Loaded!')
If (Song['songtype'] = 'S') then // The script works only with songtype S but you can add more types
    Pal.LockExecution; // Speed some things up
    const arrayNum = 10; // Max Number of artists
    const sepLines = '&'; // Delimiter to Separate Artists, change this to the delimiter you use (like ft or AND or , etc) you cn only use 1 delimiter
    var cnt : Integer = 0;
    var x : Integer = 0; // current character position
    var y : Integer = 0; // counting for array
    var yArray : Array[0..arrayNum] of String;
    var singer : String;

    singer := Song['artist'];
    while singer <> '' do
        var strTmp : String = singer;
        x := Pos(sepLines,singer);
        if  x > 0 then
            Delete (strTmp, x, Length (strTmp));
            Delete (singer, 1, x);
            strTmp := singer;
            singer := '';
        yArray[y] := strTmp;
        //WriteLn('Field #'+IntToStr(y)+': '+Trim(yArray[y])); // Uncomment this line to see what is happening in the Output Window
            cnt := ExecSQL('UPDATE songlist SET date_artist_played = :DatePlayed WHERE artist = :artist OR artist LIKE :artist1 OR artist LIKE :artist2 OR artist LIKE :artist3', [Now,Trim(yArray[y]),'%'+sepLines+' '+Trim(yArray[y]),Trim(yArray[y])+' '+sepLines+'%','%'+sepLines+' '+Trim(yArray[y])+' '+sepLines+'%']);
            //WriteLn(IntToStr(cnt)+' records were updated'); // Uncomment this line to see what is happening in the Output Window
        y := y + 1;
   Pal.UnLockExecution; // Slow some things down

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours [ DST ]

Who is online

Users browsing this forum: No registered users and 6 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