Jump to content

PAL Question: Best Way to Handle a Multiple-Artist Query


Recommended Posts

I am knee deep in PAL and MySQL and I am a bit stumped.

 

Each song I have is attached to 10 associated artists. What I want to do is:

- Determine which artists I can play, based on my station rules and the Category I want (I have one named Normal Rotation)

- Determine the least recently played song

- Place this song into a Playlist to be inserted into the Queue at a designed time

 

So in essence I should have a list of 10 songs (at most) that would fit next to the song I have queued up.

 

The question I have is how would I even attempt this? I assume I should make an array and circle through each artist seeing when they last played, then if that artist can play I can circle through the list of songs finding the oldest play. That makes sense to me...

 

Though how do I get the Artist separation/Song separation rule minutes to compare with what's available?

 

Hopefully this makes sense?

 

Thanks!

Link to comment
Share on other sites

Thank you for the links though I do know the basic ins and outs of PAL, but the problem is that it's restrictive, so I look for easy solutions. They aren't always as easy as I wish for, of course.

 

So far I have most of my code done, now I just need to SQL query using these parameters:

 

var tArtist: Integer = PlaylistRules.MinArtistTime;

var tTitle: Integer = PlaylistRules.MinSongTime;

 

So I query to see if the artist last played, if the artist hasn't played in awhile THEN I can query all their songs, finding the song that last played. Maybe adding the caveat that it is last played in a category of my choice.

 

Hopefully this makes more sense now. :)

 

A bit of time later I have a pretty nice solution...

 

const catName = 'TopSongList';
CAT[catName].Clear; //Clear the Category Before Replacing
const aHi = 9; //Total items in the aArray, they are just Artists
var tArtist: Integer = PlaylistRules.MinArtistTime;
var  tTitle: Integer = PlaylistRules.MinSongTime;
var l : Integer = 0; //counting for loops
var k : Integer = 0; //counting for total array

while k  begin
  Q := Query('SELECT * FROM songlist WHERE (artist = :artists) AND (weight > :weights) ORDER BY date_played ASC LIMIT 1',[aArray[k],aHi],True);

  if (Q['title']  '') AND (l      begin
     If DateTime(Now - (IntToStr(tArtist)/1440)) > Q['date_artist_played'] then
        Begin
          If DateTime(Now - (IntToStr(tTitle)/1440)) > Q['date_title_played'] then
            Begin
              WriteLn(IntToStr(l)+') '+aArray[k]+' - '+Q['title']);
              CAT[catName].AddFile(Q['filename'], ipBottom);
              l := l + 1;
            End;
        End;
    end;
  k := k + 1;
  Q.Free;
end;

 

The only problem is that there is a Memory leak: Warning: Memoryleak detected (instance of class TCategoryTree)

 

So I guess that's the final bit I need to help plug and then this should be finished.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...