Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Streaming Information HTTP Question

Ruboneout Shoreman
Registered User
Join date: 29 Jul 2009
Posts: 38
01-30-2010 12:47
A few days ago I opened up a post about how I would stream the information of my friends radio stream station onto a board in second life. Since then, I have been reading into HTTP and trying to figure out some stuff. My friend has 2 links that he sent one. One has a song name, and one has an online or offline status. This is the link that he sent me. http://shoutcast.mixstream.net/js/status/uk4-free:18496. When you go to it, it will say document.write('Online');... I was wondering how I would go about extracting the Online, or Offline part of that sentence.... Thank you...
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
01-30-2010 13:51
If you're *SURE* that will always be the format, you can do this..

string result = llGetSubString(message, 16, -1);

result = llGetSubString(result, 0, llSubStringIndex(result, "'";) - 1);

..where 'message' is the string from the webserver. The first line chops off the first 15 characters and the 2nd line searchs for a ' character and chops that and the characters after that off.
_____________________
Sick of sims locking up every time somebody TPs in? Vote for SVC-3895!!!
- Go here: https://jira.secondlife.com/browse/SVC-3895
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Ruboneout Shoreman
Registered User
Join date: 29 Jul 2009
Posts: 38
01-30-2010 13:58
I am probably the worst with HTTP and strings out of EVERYTHING, all these numbers to cut stuff off and everything, just seems confusing to me, however, I am trying to learn... Could anyone set this up for me, because I have a feeling it pretty much stupid easy....
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
01-30-2010 19:09
Here ya go..

string URL = "http://shoutcast.mixstream.net/js/status/uk4-free:18496";
float UPDATE_TIME = 60.0;

key gId = "";
string gText;

Update()
{
gId = llHTTPRequest(URL, [], "";);
}

default
{
state_entry()
{
llSetText ("", ZERO_VECTOR, 1.0);
llSetTimerEvent (UPDATE_TIME);
Update();
}

timer()
{
Update();
}

http_response (key id, integer status, list data, string body)
{
if (gId == id)
{
integer i = llSubStringIndex (body, "'";);

string text = llGetSubString(body, i + 1, -1);

text = llGetSubString(text, 0, llSubStringIndex(text, "'";) - 1);

if (text != gText)
{
gText = text;
llSetText ("Status: " + text, <1.0, 1.0, 1.0>, 1.0);
}
}
}
}
_____________________
Sick of sims locking up every time somebody TPs in? Vote for SVC-3895!!!
- Go here: https://jira.secondlife.com/browse/SVC-3895
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Ruboneout Shoreman
Registered User
Join date: 29 Jul 2009
Posts: 38
01-30-2010 23:38
Thank you... I hope i wasn't a pain asking for that or anything, Im just trying to figure scripting out on my own. i dont have any former programming skills, so it is pretty much a bumpy road for me in a way... I'm working on it though... I understand what u did, so it was just nice to see it put together. Thank you.
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
01-31-2010 07:52
You're welcome!
_____________________
Sick of sims locking up every time somebody TPs in? Vote for SVC-3895!!!
- Go here: https://jira.secondlife.com/browse/SVC-3895
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left