This script is a work in progress. It is designed to parse the xml file from Shoutcast V2 servers and output it to a prim. Please note that this does not work on Shoutcast V1 or Icecast yet.
Here is my new version. You will also need the Furware text script and a Furware Text board generated to use this script. There will be an example board rezzed in the Free Scripts area of the Brayla Sana Gallery sim (grid.kitely.com:8002:Brayla Sana Gallery) which is hypergrid enabled.
I need an Icecast station to make that version of the script. If you know of one, IM me inworld or post it in the OSSL Google+ group so I can make that version.
string LatestItem;
string purl;
string RSSurl;
key PageKey;
integer begin;
integer end;
integer titlemargin = 1;
string item;
string current = "Empty";
string oldcurrent = "Empty";
string l1 = "Empty";
string l2 = "Empty";
string l3 = "Empty";
string l4 = "Empty";
string bitrate;
string GenreType;
string Station;
string listeno;
integer gListener;
integer ch;
default
{
on_rez(integer a)
{
llResetScript();
}
state_entry ()
{
llResetScript();
titlemargin = integer(llList2String(llGetPrimitiveParams([ PRIM_DESC ]), 0));
purl = llGetParcelMusicURL();
if (purl == "")
{
llOwnerSay("No station found or Parcel Permission problem. Setting to Default. Make sure the URL does not have a trailing slash or a semicolon and a trailing slash.");
purl = "http://rosetta.shoutca.st:8201";
}
RSSurl = purl + "/stats";
llSetTimerEvent(20); //refreshes every 20 seconds
PageKey = llHTTPRequest(RSSurl,[],"");
}
touch_start(integer total_number)
{
llListenRemove(gListener);
key user = llDetectedKey(0);
gListener = llListen(ch, "", user, "");
llDialog(user, "End Text Trim Amount (to remove extra data in brackets sometimes seen at the end)", ["1 (Default)", "7"], ch);
}
listen(integer ch, string name, key user, string message)
{
if (message == "7")
{
titlemargin = 7;
string sm = (string)titlemargin;
llSetObjectDesc(sm);
}
if (message == "1 (Default)")
{
titlemargin = 1;
string sm = (string)titlemargin;
llSetObjectDesc(sm);
}
}
timer ()
{
purl = llGetParcelMusicURL();
if (purl == "")
{
llOwnerSay("No station found or Parcel Permission problem. Setting to Default.");
purl = "http://rosetta.shoutca.st:8201";
}
RSSurl = purl + "/stats";
LatestItem = item;
PageKey = llHTTPRequest(RSSurl,[],"");
// llOwnerSay(purl + " " +RSSurl); //Debug
titlemargin = integer(llList2String(llGetPrimitiveParams([ PRIM_DESC ]), 0));
if (titlemargin == 0)
{
titlemargin = 1;
}
llListenRemove(gListener);
}
http_response (key request_id, integer status, list metadata, string body)
{
begin = llSubStringIndex(body, "<SHOUTCASTSERVER>");
end = llSubStringIndex(body, "</SHOUTCASTSERVER>");
item = llGetSubString(body, begin, end);
if (item != LatestItem)
{
oldcurrent = current;
begin = llSubStringIndex(item, "<SONGTITLE>") + 11;
end = llSubStringIndex(item, "</SONGTITLE>") - titlemargin;
current = llGetSubString(item, begin, end);
current = llDumpList2String( llParseStringKeepNulls( current, ["& apos;"], [] ), "'" ); // remove the space after the ampersand
current = llDumpList2String( llParseStringKeepNulls( current, ["& amp;"], [] ), "&" ); // remove the space after the ampersand
current = llDumpList2String( llParseStringKeepNulls( current, ["& quot;"], [] ), " " ); // remove the space after the ampersand
begin = llSubStringIndex(item, "<BITRATE>") + 9;
end = llSubStringIndex(item, "</BITRATE>") - 1;
bitrate = llGetSubString(item, begin, end);
begin = llSubStringIndex(item, "<SERVERTITLE>") + 13;
end = llSubStringIndex(item, "</SERVERTITLE>") - 1;
Station = llGetSubString(item, begin, end);
begin = llSubStringIndex(item, "<CURRENTLISTENERS>") + 18;
end = llSubStringIndex(item, "</CURRENTLISTENERS>") - 1;
listeno = llGetSubString(item, begin, end);
begin = llSubStringIndex(item, "<SERVERGENRE>") + 13;
end = llSubStringIndex(item, "</SERVERGENRE>") - 1;
GenreType = llGetSubString(item, begin, end);
if (oldcurrent != current)
{
l4 = l3;
l3 = l2;
l2 = l1;
l1 = oldcurrent;
// llOwnerSay("Now Playing: " + current);
// llOwnerSay("Station: " + Station);
llMessageLinked(LINK_SET, 0, "Station: " + Station, "fw_data : stationname");
llMessageLinked(LINK_SET, 0, "Genre: " + GenreType + " Listeners: " + listeno + " Bit Rate: " + bitrate + " kbps", "fw_data : data");
llMessageLinked(LINK_SET, 0, "a=center", "fw_conf : data");
llMessageLinked(LINK_SET, 0, "Now Playing: ", "fw_data : nowplaying");
llMessageLinked(LINK_SET, 0, current, "fw_data : currentsong");
llMessageLinked(LINK_SET, 0, "Recent Songs: ", "fw_data : previous");
llMessageLinked(LINK_SET, 0, l1, "fw_data : r1");
llMessageLinked(LINK_SET, 0, l2, "fw_data : r2");
llMessageLinked(LINK_SET, 0, l3, "fw_data : r3");
llMessageLinked(LINK_SET, 0, l4, "fw_data : r4");
}
}
}
} // end