Laufiair Hexicola Posted January 4, 2018 Share Posted January 4, 2018 I know the last reponse was back in October however it seemed relevent to post this in here. I'm trying to pull stats from a shoutcast v2 stream and while it gives me my floating text, it's not displaying the relevant info(the song title). I can confirm that my IP, while being v2, gives me stats from 7.html The script I'm working with: string stream = "http://198.15.88.42:8042"; key kSentRequest; default { state_entry() { kSentRequest=llHTTPRequest(stream + "/7", [HTTP_USER_AGENT, "LSL_Script (Mozilla Compatible)"],""); } http_response (key kRecRequest, integer intStatus, list lstMeta, string strBody) { if (kRecRequest == kSentRequest) { list html = llParseString2List(strBody,["<body>", "</body>"],[]); string info = (llList2String(html,6)); list status = llCSV2List(info); llSetText ("Now playing on Aristide Radio \n"+llList2String(status,6),<1,1,1>,1); kSentRequest = NULL_KEY; } } } Link to comment Share on other sites More sharing options...
Oz Linden Posted January 4, 2018 Author Share Posted January 4, 2018 1 hour ago, Laufiair Hexicola said: Your http request is fine - you're not parsing the response correctly. What's coming back from the server is: <html><body>1,1,10,50,1,96,Abney Park - Under the Radar</body></html> so to get the song title, you need: list result = llParseString2List(strBody,["<html><body>", ",", "</body></html>"],[]); string songtitle = llList2String(result,6); 1 Link to comment Share on other sites More sharing options...
Laufiair Hexicola Posted January 5, 2018 Share Posted January 5, 2018 Hello Oz, I changed the list and string around and it didn't seem to do anything. I did try to see if I could see the entire string and that didn't show anything either. key http_request_id; default { state_entry() { http_request_id = llHTTPRequest("http://198.15.88.42:8042/7.html", [HTTP_USER_AGENT, "LSL_Script_(Mozilla Compatible)"],""); } http_response(key request_id, integer status, list metadata, string body) { if (request_id == http_request_id) { list result = llParseString2List(body,["<html><body>", ", ", "</body></html>"],[]); string songtitle = llList2String(result,6); // list status = llCSV2List(songtitle); llSetText ("Now playing on Aristide Radio \n"+(string)songtitle,<1,1,1>,1); } } } Link to comment Share on other sites More sharing options...
Oz Linden Posted January 5, 2018 Author Share Posted January 5, 2018 You used ["<html><body>", ", ", "</body></html>"] but it should be ["<html><body>", ",", "</body></html>"] note that there is no space following the comma that's inside quotes. That list specifies the parts of the string to be removed and treated as separators when constructing the list; since there are no spaces following the commas in the string returned by the shoutcast service, you get a list containing a single string that includes everything but the tags. 2 Link to comment Share on other sites More sharing options...
arton Rotaru Posted January 5, 2018 Share Posted January 5, 2018 12 hours ago, Laufiair Hexicola said: I did try to see if I could see the entire string and that didn't show anything either. You also want to avoid the word "Script" in the header. Some servers seem to skip requests with such lettering. [HTTP_USER_AGENT, "LSL (Mozilla Compatible)"] Should do the trick. Link to comment Share on other sites More sharing options...
Laufiair Hexicola Posted January 5, 2018 Share Posted January 5, 2018 3 hours ago, arton Rotaru said: You also want to avoid the word "Script" in the header. Some servers seem to skip requests with such lettering. [HTTP_USER_AGENT, "LSL (Mozilla Compatible)"] Should do the trick. That didn't do anything - even put an underscore between LSL and Mozilla and no change. It's displaying the text, but not the song name. Link to comment Share on other sites More sharing options...
Love Zhaoying Posted January 5, 2018 Share Posted January 5, 2018 1 minute ago, Laufiair Hexicola said: That didn't do anything - even put an underscore between LSL and Mozilla and no change. It's displaying the text, but not the song name. Did you follow Oz's advice? You have an extra space after one of your quoted commas. He said above: You used ["<html><body>", ", ", "</body></html>"] but it should be ["<html><body>", ",", "</body></html>"] note that there is no space following the comma that's inside quotes. That list specifies the parts of the string to be removed and treated as separators when constructing the list; since there are no spaces following the commas in the string returned by the shoutcast service, you get a list containing a single string that includes everything but the tags. Link to comment Share on other sites More sharing options...
Laufiair Hexicola Posted January 5, 2018 Share Posted January 5, 2018 wow that's um.. not sure how I overlooked that one, but yes - it's all working now. Thanks Love, Oz and Arton, appreciate it! 2 Link to comment Share on other sites More sharing options...
arton Rotaru Posted January 5, 2018 Share Posted January 5, 2018 5 minutes ago, Laufiair Hexicola said: That didn't do anything You have to fix the separator list as well indeed. Link to comment Share on other sites More sharing options...
Love Zhaoying Posted January 5, 2018 Share Posted January 5, 2018 15 minutes ago, Laufiair Hexicola said: not sure how I overlooked that one Perhaps you didn't see the update because of how Oz replied. (The forum only notifies you of replies when you are "quoted".) It's all good! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now