Hi there.
With the script I have below (Written originally by Charlie Davy and the string replace function scripted by Cad), it works great for sweepers etc being excluded from publishing to a file of now playing information based on that anything less than 90 seconds is excluded.
But…a problem arises when playing the beds for the news! they are longer than 90 seconds. So if these were tagged in some way (also I need to know how I would go about that), is there script that could be used to exclude these tagged items from being logged/published, in a similar way to the current way of basing an item by it’s length?
[code]// StringReplace
// Written by Cad Delworth CEng MBCS CITP
// (Clearances Manager, Leith FM, Edinburgh, Scotland)
// A mAirList script function which replaces characters in a string.
// Copy the function below into any script which requires a string replace function.
function Replace(sSource: string; sFind: string; sReplace: string): String;
var
iLenFind, iPos: integer;
sString, sOutput: string;
begin
// Store the length of the ‘find’ string
iLenFind := Length(sFind);
// The default output string is the input string
// (in case no matches are present)
sString := sSource;
// Now search repeatedly for sFind until it isn’t there any more
repeat
// Are there any 'find' strings in sString?
iPos := Pos(sFind, sString);
if iPos > 0 then
begin
// Yes, form a 'replaced' string by string slicing
sOutput := Copy(sString, 1, iPos - 1) + sReplace;
sOutput := sOutput + Copy(sString, iPos + Length(sFind), Length(sString) - iPos + Length(sFind));
// Now copy sOutput back into sString for the next loop
sString := sOutput;
end;
until iPos = 0;
// We’re finished, return the output string
Result := sString;
end;
// Intelligent Now Playing Script v2
// by Charlie Davy
// last modified 16th January 2009
// This script examines each audio item played via a Player and performs a task based upon the track’s length.
// The 3 settings below work for most situations, however you can fine-tune them if you wish.
// The last.fm links work for most artist/groups - it adds a nice touch, I think.
// Update: The OnAir switch is considered within this script, if you are “Off Air”, this script does nothing.
// If you are “On Air”, the script runs as normal. Useful in a multi-studio environment where pre-recorded
// shows may interfer with your live “now playing” display!
// IMPORTANT!! You MUST rename this file to .mls when adding it to mAirListConfig
const
IDENT = 900000000; // 90 seconds
MUSIC = 900000000; // 90 seconds
PRE_REC = 4200000000; // 7 minute
procedure OnPlayerStart(PlayerControl: IPlayerControl; Item: IPlaylistItem);
var sl: TStringList;
begin
if Engine.GetOnAir = False then begin
SystemLog(‘mAirList is in production mode, so no action taken…’);
sl := TStringList.Create;
sl.Add(‘LiveWire Radio’);
sl.SaveToFile(‘C:\Users\Ryan\Documents_RADIO\site\nowplaying\nowplaying.php’);
sl.Free;
// If the track is over 7 minutes, assume it’s a pre-recorded programme
end else if (Item.GetDuration > PRE_REC) then begin
sl := TStringList.Create;
sl.Add(‘More music soon’);
sl.SaveToFile(‘C:\Users\Ryan\Documents\nowplaying\nowplaying.php’);
sl.Free;
SystemLog(‘This item is a pre-record or longer than 7 minutes…’);
// If the track is more than 90 seconds, assume it’s a song
end else if (Item.GetDuration > MUSIC) then begin
sl := TStringList.Create;
sl.Add(’<?php’);
sl.Add(‘ob_start();’);
sl.Add(‘echo rawurldecode("http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=’ + Item.GetArtist + ‘&api_key=097a7ab0f5b56a894eb7a25e1c51b0da");’, ‘’’’, ‘%27’));
sl.Add(’$url = ob_get_clean();’);
sl.Add(‘if (!$xmlObj = simplexml_load_file($url)) {’);
sl.Add(‘echo “Error reading XML file”;}’);
sl.Add(‘foreach($xmlObj as $artist) {’);
sl.Add(‘ob_start();’);
sl.Add(‘echo $artist->name;’);
sl.Add(’$name = ob_get_clean();’);
sl.Add(‘ob_start();’);
sl.Add(‘echo $artist->image[2];’);
sl.Add(’$image = ob_get_clean();’);
sl.Add(‘ob_start();’);
sl.Add(‘echo $artist->bio->summary;’);
sl.Add(’$bio = ob_get_clean();’);
sl.Add(’}’);
sl.Add(’?>’);
sl.SaveToFile(‘C:\Users\Ryan\Documents_RADIO\site\nowplaying\artist.php’);
sl.Free;
sl := TStringList.Create;
sl.Add(’<?php’);
sl.Add(‘ob_start();’);
sl.Add(‘echo rawurldecode("http://ws.audioscrobbler.com/2.0/?method=track.getinfo&artist=’ + Item.GetArtist + ‘&track=’ + Item.GetTitle + ‘&api_key=097a7ab0f5b56a894eb7a25e1c51b0da");’, ‘’’’, ‘%27’));
sl.Add(’$url = ob_get_clean();’);
sl.Add(‘if (!$xmlObj = simplexml_load_file($url)) { ‘);
sl.Add(‘echo “Error reading XML file”;}’);
sl.Add(‘foreach($xmlObj as $track){’);
sl.Add(‘ob_start();’);
sl.Add(‘echo $track->name;’);
sl.Add(’$trackname = ob_get_clean();’);
sl.Add(‘ob_start();’);
sl.Add(‘echo $track->wiki->content;’);
sl.Add(’$trackwiki = ob_get_clean();’);
sl.Add(’}’);
sl.Add(’?>’);
sl.SaveToFile(‘C:\Users\Ryan\Documents_RADIO\site\nowplaying\track.php’);
sl.Free;
sl := TStringList.Create;
sl.Add(’’ + Item.GetArtist + ’ - ’ + Item.GetTitle + ‘’);
sl.SaveToFile(‘C:\Users\Ryan\Documents_RADIO\site\nowplaying\nowplaying.php’);
sl.Free;
SystemLog('Now Playing… ’ + Item.GetArtist + ’ - ’ + Item.GetTitle);
end;
end;
begin
end.[/code]
Cheers, Ryan.