Note that this Wiki is a work in progress, items may not be updated or may disappear entirely as the pages are updated.
Pull from Muliple categories and Fill 1 category
From SpacialAudio
This script will pull music from multiple category folders of your choice,
based on rules, and fill the category you want it to.
It will cycle through the category list to pull from until the duration specified has been reached.
The script has only been tested for a 1 hour show and 30 minutes on a 1.4 gig with 192 megs of memory and on an 850 with 256 megs of memory.
Be sure to give it plenty of time to work before the show should run.
There are no implied warranties or claims. This script is as is.
Feel free to modify or what ever.
1. Make sure the category you are pulling from has enough songs for the rules
2. Make sure the to categories you are pulling from and filling exist.
3. You may have to play with your rules some to get it to pull the way you want
4. I have tried to prevent duplicate artists but don't be surprised if some show up
(tags , inconsistent artist names etc.)
If you get access memory problem.
Check to make sure that all the category folders involved exist
You may download the script here. http://spacialaudio.com/knowledge/attachment.php?attId=50
Above link retrieved from archive.org:
{*********************************************
emptys a category folder and selects from more than 1 category to fill the empty one
categories to pull from are cycled theough till duration is satisfied
cat3.pal
***********************************************
Make sure the CategoryToPullFrom has songs in it
***********************************************}
PAL.loop := true ;
const CatToFill : String = 'Ashow';
const ShowDuration : integer = 3600000; //1 hour in milli seconds
var D, D2 : TDataSet;
var SonginfoT : TSongInfo;
var CategoryList : TStringList;
var CatlistIndex : integer ;
var totalduration : integer ;
var durationinminutes : integer;
var songcount : integer ;
var catID : integer ;
var idofsong : integer ;
var artistcount : integer;
var x : integer;
var logicswitch : integer;
var Artist : string;
var CategoryToPullFrom : string;
var HoldArtist : string;
var ExistingArtist : boolean;
songcount := 0;
durationinminutes :=0 ;
totalduration := 0 ;
artistcount := 0;
ExistingArtist := false ;
CategoryList := TStringList.Create;
CategoryList.add ('Tracks');
CategoryList.add ('bigband');
CategoryList.add ('blues');
CatlistIndex := 0;
HoldArtist := '';
//DELETE songs from CatToFill
D2:=Query('SELECT ID, name FROM category WHERE name = :cat', [CatToFill], True);
writeln ('Deleting songs from category ' + D2['name']);
ExecSQL('DELETE FROM categorylist WHERE categoryID = :categoryID', [D2['ID']]);
catID := D2['ID'] ;
D2.free ;
writeln ( CatToFill + ' now empty');
//Start PAL for filling CatToFill pulling from CategoryToPullFrom.
while (totalduration <= ShowDuration) do
begin
//which category to pull from
If CatListIndex >= CategoryList.Count then
CatListIndex := 0;
CategoryToPullFrom := CategoryList.Get(CatListIndex);
//Writeln(CategoryToPullFrom);
{**********************************************************
here are 2 different ways to choose the songs you can add more.
the randomInt is 0 based so if you want 3 different sets of logic
you use 3 but the numbers returned start at 0 so for 3 you get 0,1,2
*********************************************************}
logicswitch := RandomInt(2);
Case CatListIndex of
0,3: begin //jazz
case logicswitch of
0 : SonginfoT := Cat[CategoryToPullFrom].ChooseSong(smRandom,EnforceRules);
1 : SonginfoT := Cat[CategoryToPullFrom].ChooseSong(smLemmingLogic,NoRules);
end;
end;
1: begin //bigband
case logicswitch of
0 : SonginfoT := Cat[CategoryToPullFrom].ChooseSong(smLRP,NoRules);
1 : SonginfoT := Cat[CategoryToPullFrom].ChooseSong(smLemmingLogic,NoRules);
end;
end;
2: begin // you get the idea
case logicswitch of
0 : SonginfoT := Cat[CategoryToPullFrom].ChooseSong(smRandom,NoRules);
1 : SonginfoT := Cat[CategoryToPullFrom].ChooseSong(smLemmingLogic,NoRules);
end;
end;
end;
{ case logicswitch of
0 : SonginfoT := Cat[CategoryToPullFrom].ChooseSong(smRandom,NoRules);
1 : SonginfoT := Cat[CategoryToPullFrom].ChooseSong(smLemmingLogic,NoRules);
end;}
Artist := Trim(SonginfoT['artist']) ;
writeln('artist from choose = ' + artist);
D2 := Query('SELECT songid FROM categorylist ' +
'WHERE (songid = :sid) and (categoryID = :cid )', [ SonginfoT['songID'],catID], True);
If D2.EOF then
begin
//see it artists has already been put in show folder
x := Pos(Artist, HoldArtist);
if x > 0 then
ExistingArtist := True
else
ExistingArtist := False;
if not ExistingArtist then
begin
if totalduration <= ShowDuration then
begin
Writeln( 'Adding from ' + CategoryToPullFrom);
writeln ( SonginfoT['artist'] + ', ' + SonginfoT['title'] );
HoldArtist := Holdartist + ' ';
CAT[CatToFill].AddFile(SonginfoT['filename'],ipTop);
artistcount := artistcount + 1;
songcount := songcount + 1;
CatListIndex := CatListIndex + 1;
totalduration := totalduration + SonginfoT['duration'];
end;
end;
end;
D2.Free
end;
durationinminutes := (totalduration / 1000) /60;
Writeln ( inttostr(songcount) + ' Songs were added for a total of ' +
'approximatly ' + inttostr(durationinminutes) + ' minutes');
PAL.WaitForTime(T['23:59:59']); {Wait for next day}
