{*
TuneIn.com [Previously known as RadioTime.com]
Script to submit song info to the RadioTime AIR API (http://inside.radiotime.com/developers/api/air).
The stationId, partnerId and partnerKey values need to be set for this to work.
*}
const STATION_ID = 'sXXXX';
const PARTNER_ID = 'partnerId';
const PARTNER_KEY = 'partnerKey';
var player : TPlayer;
var song : TSongInfo;
var baseUrl: String;
FUNCTION urlEncode(s: String): String; forward;
PROCEDURE update(stationId, partnerId, partnerKey, artist, title : String); forward;
{Main}
PAL.Loop := true;
PAL.WaitForPlayCount(1);
player := ActivePlayer;
IF ( player <> NIL ) THEN
BEGIN
IF ( player.Duration > 45000 ) THEN
BEGIN
song := player.GetSongInfo;
IF ( song <> NIL ) THEN
BEGIN
update(STATION_ID, PARTNER_ID, PARTNER_KEY, song['artist'],song['title']);
song.Free;
END;
END;
END;
FUNCTION urlEncode(s: String): String;
BEGIN
var index : integer;
var intVal : integer;
result := '';
PAL.LockExecution;
IF (Length(s)) > 0 THEN
BEGIN
FOR index := 1 TO length(s) DO
BEGIN
intVal := Ord(s[index]);
IF ((intVal > 47) AND (intVal < 58)) OR ((intVal > 64) AND (intVal < 91)) OR ((intVal > 96) AND (intVal < 123)) THEN
BEGIN
result := result + (s[index])
END
ELSE
BEGIN
IF ( intVal < 128 ) THEN
BEGIN
result := result + '%' + IntToHex(intVal, 2);
END
ELSE IF ( intVal < 2048 ) THEN
BEGIN
result := result + '%' + IntToHex( $C0 or Trunc( intVal / 64 ), 2 ) + '%' + IntToHex( $BF and intVal, 2 );
END
ELSE
BEGIN
// not yet supported
END;
END;
END;
END;
PAL.UnlockExecution;
END;
PROCEDURE update(stationId, partnerId, partnerKey, artist, title : String);
BEGIN
var req : String;
req := 'http://air.radiotime.com/Playing.ashx?id=' + stationId
+ '&partnerId=' + urlEncode(partnerId)
+ '&partnerKey=' + urlEncode(partnerKey)
+ '&title=' + urlEncode(title)
+ '&artist=' + urlEncode(artist);
WebToStr(req);
END;
PAL Script - TuneIn Script to Submit Track Info (this script is included in SAM Broadcaster)
Have more questions? Submit a request
Comments