Jump to content

radio script gridwide linked to a unique radio station notecard in a server ?


Skywalker Scofield
 Share

You are about to reply to a thread that has been inactive for 1254 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello,

I am searching for a script that would make it possible for a radio to search its stations genre, names and url not in a notecard attached in the radio itself, but in one or more notecard(s) included in a central server not in the same sim. That would make it possible to update all the linked radios gridwide in one unique update of the notecard(s) in the central server.

so this does not consist in sending updated notecard to the owner of the radio (already existing). The radio has no notecard in it. Only the script that communicates with central notecards server.

Thank you in advance for any help or offer.

Skywalker.

Edited by Skywalker Scofield
replace one word
Link to comment
Share on other sites

You could do that either by hosting the data bank of URLs on an external server or by having an (as-yet-unavailable) grid-wide Experience so that you could store the information in KVP.  Failing those two options, you're stuck with the old standby of setting up a server somewhere in world and communicating by HTTP or e-mail, realizing that the system will be very hard to manage if you ever have to change the server.

  • Thanks 1
Link to comment
Share on other sites

Thank you Rolig. That is very technical for me. I can easily build a googlsheet as external server for making possible http request, but i would not be capable of transforming an existing radio script based on local notecard to make it work properly with external googlesheet. May be someone has an idea ?

 

Rolig : just noticed we joined SL the same day : Oct 9, 2009 ! ;)

Edited by Skywalker Scofield
Link to comment
Share on other sites

40 minutes ago, Skywalker Scofield said:

Rolig : just noticed we joined SL the same day : Oct 9, 2009 !

Not really.  That's just when they replaced the ancient forum software with the extinct version (which was followed by the very old version and then the old version and a couple of modifications since).  In 2009, they messed up our join dates by setting them to the start date of that forum version. Surprisingly, they didn't wipe out other parts of our forum profiles. I'm older than you think, in SL and RL.

40 minutes ago, Skywalker Scofield said:

i would not be capable of transforming an existing radio script based on local notecard to make it work properly with external googlesheet. May be someone has an idea ?

There are several places to look.  Start with some of the posts here by Xiija, like this one 

 

Edited by Rolig Loon
  • Thanks 1
Link to comment
Share on other sites

It must be noted that last year, Google had changed their API. Ways of storing and retrieving data from their spreadsheets have changed and the older methods no longer work.
If I understand correctly (but I would welcome getting corrected here) we can't even use Google sheets for this purpose anymore. Which bites because I had been planning making a super simple grid-wide product server and for that I would have the server post it's URI remotely, and have the clients retrieve it upon activation which is basically the same principle as what you had in mind for the radio.

  • Thanks 1
Link to comment
Share on other sites

2 hours ago, Fritigern Gothly said:

It must be noted that last year, Google had changed their API. Ways of storing and retrieving data from their spreadsheets have changed and the older methods no longer work.
If I understand correctly (but I would welcome getting corrected here) we can't even use Google sheets for this purpose anymore. Which bites because I had been planning making a super simple grid-wide product server and for that I would have the server post it's URI remotely, and have the clients retrieve it upon activation which is basically the same principle as what you had in mind for the radio.

Someone somewhere (here or the Library forum maybe) mentioned a website that hosted a free online database that could be accessed by LSL scripts.

A quick Google for "free database online" put Zoho (which sounds vaguely familiar) at the top of my search results, though there's others there too.

I haven't looked into any of these myself, but I'd be willing to bet there's something useful out there.

Link to comment
Share on other sites

  • Moles
10 hours ago, Rolig Loon said:

Not really.  That's just when they replaced the ancient forum software with the extinct version (which was followed by the very old version and then the old version and a couple of modifications since).  In 2009, they messed up our join dates by setting them to the start date of that forum version. Surprisingly, they didn't wipe out other parts of our forum profiles. I'm older than you think, in SL and RL.

There are several places to look.  Start with some of the posts here by Xiija, like this one 

 

I don't think you necessarily need a grid-wide experience -- users would have to allow the experience on their land, just as they do with AvSitter to make props auto-attach properly, but that's not a big issue, I'd have thought.

The alternative would be to host your own MySql database and communicate with it via LSL and php.    That's not actually too difficult -- I found some very good instructions here 

http://www.drnadolny.com/uploads/6/0/0/2/6002231/databases.pdf

and  there are plenty of sites offering to host php/MySql for free.   

There's also this, from the old LSL wiki, which might be useful

http://lslwiki.digiworldz.com/lslwiki/wakka.php?wakka=ExamplellHTTPRequest&show_comments=1

But, as I say, I would certainly first consider trying to do it by KVP and asking customers to allow the experience on their land, as do many content creators when they want to make force-attach and force-teleport work.   That's the easiest way to do it, I think.    The KVP is simple enough -- I'll gladly help here if you need it.

I know how to post data to Google Sheets from SL but if it's possible for  scripts in SL to read from them directly, I've yet to find a way (and would love to know how to do it, if anyone can help).

Edited by Quartz Mole
  • Like 2
  • Thanks 1
Link to comment
Share on other sites

1 hour ago, Quartz Mole said:

I know how to post data to Google Sheets from SL but if it's possible for  scripts in SL to read from them directly, I've yet to find a way (and would love to know how to do it, if anyone can help).

@Quartz Mole see @Xiija's answer in storing data on the forum.

Edited by Rachel1206
  • Thanks 1
Link to comment
Share on other sites

Probably using an alternative store (either Experience persistent KVP or external storage) is the right solution, but just in case it matters, it's not necessary that remote scripts get copies of notecards in order to read from them; they only need the notecards' UUIDs, which change each time the object is updated. So if there's a central server that stores the notecards, it merely needs to communicate those changed UUIDs to the client scripts, not transfer actual notecards.

That doesn't solve the whole problem, though, because you're still stuck with clunky, bug-ridden old llEmail() as the only purely internal, non-ephemeral object address for sending data that doesn't involve Experiences. (See @Rolig Loon's post above.)

Also, I kinda suspect it was intended that the server do the searching by genre, artist, etc., and just hand off the results to the client radio scripts. That would mean notecard distribution wasn't the issue anyway -- and it would also mean that there may be more than mere storage required of the data service, whether it's SL-internal or external. I mean, there's probably a search functionality in the Google Sheets API, but it may be more natural with other web service DBs.

(Doing such searches using Experience KVP might involve building and maintaining content-specific indices, to avoid what amounts to a table scan of the whole KVP for each query.)

  • Like 1
Link to comment
Share on other sites

You can create a github account and then you can add any kind of text content you like and see it as raw, here is a random example I picked by searching "pdf":

https://raw.githubusercontent.com/mozilla/pdf.js/master/.travis.yml

This kind of page can be read from LSL, like so:

 

string url = "https://raw.githubusercontent.com/mozilla/pdf.js/master/.travis.yml" ;
key http_request_id ;

default
{
   state_entry()
   {
       http_request_id = llHTTPRequest(url, [], "");
   }

   http_response(key request_id, integer status, list metadata, string body)
   {
       if (request_id == http_request_id)
       {
           llOwnerSay(body);
       }
   }
}

http://wiki.secondlife.com/wiki/LlHTTPRequest

The easiest would be to have your page containing json, you also need to keep the length under 2048... This should work with any site that accepts to display raw text.

 

  • Thanks 1
Link to comment
Share on other sites

9 hours ago, Sabrina Tamerlane said:

You can create a github account and then you can add any kind of text content you like and see it as raw, here is a random example I picked by searching "pdf":

https://raw.githubusercontent.com/mozilla/pdf.js/master/.travis.yml

This kind of page can be read from LSL, like so:

 

http://wiki.secondlife.com/wiki/LlHTTPRequest

The easiest would be to have your page containing json, you also need to keep the length under 2048... This should work with any site that accepts to display raw text.

 

That is a great idea. But can it be posted to from LSL as well?
Like if I want to store the UUID of user Avatar Resident who just touched your prim to name just one example.

Link to comment
Share on other sites

4 hours ago, Fritigern Gothly said:

That is a great idea. But can it be posted to from LSL as well?
Like if I want to store the UUID of user Avatar Resident who just touched your prim to name just one example.

If you want it to work both ways I think you should look into something like a Discord bot or Wordpress...

Edited by Sabrina Tamerlane
Link to comment
Share on other sites

I *may* have a (rather cheeky) solution to the original question not involving external databases or Experiences. I offer a brief description to stimulate discussion (including why this might not work) and for the simple pleasure of (possibly) finding a cute workaround.

Inherent in the original post is that editing the central notecard causes it to have a new uuid and, thus, the problem end up being how to get this new uuid to the servers.

The cheeky solution is to use the Display Name of an Avatar as a repository for the new uuid (we need some tweaks to the uuid and these are explained below). An Avatar's display name is available grid-wide whether the avatar is logged in or not via llRequestDisplayName(key id). The idea would be to create an SL account specifically for the purpose of passing these new uuids. The servers can poll for a new uuid, say, daily, by making a call to llRequestDisplayName(key id) with the id of the avatar of this new account, convert it to a uuid and check to see if it is new, and if so, begin using it to read the new notecard.

 

Tweaks:

A display name is limited to 31 characters and a uuid has 32 significant characters (less the hyphens '-'). So we would need to encode the uuid into a base64 representation.

-------------

An example:

llOwnerSay(HexToBase64("59cf1ef6ce1bdd30ba22fe8aa404b11c")); ("59cf..." is the uuid of a notecard less the hyphens, 32 characters)

output: Wc8e9s4b3TC6Iv6KpASxHA (22 characters and thus could be used as a display name).

-----------------

Another issue is that a base64 representation includes the characters '/' and '+' neither of which are allowed in a display name. So we would need to do some post-processing to the base64 and replace those to characters with two that are allowed in a display name but are not in the base64 set. There are a number of these so it's not an issue.

If there is some interest in this solution I'll be happy to collaborate on implementing and testing it.

 

Cheers,

G

  • Like 2
Link to comment
Share on other sites

26 minutes ago, Qie Niangao said:

That's imaginative indeed! The practicality may be a bit limited because according to the Knowledge Base, a display name can be changed only once every seven days and "may take up to 24 hours to propagate throughout all of Second Life's systems" but I don't know if llRequestDisplayName() maybe gets it instantly grid-wide.

Agree. The practicality depends on the rate of change of the notecard. If that is hourly, then this isn't practical. If quarterly then it works.

Link to comment
Share on other sites

small update,  was testing with the free database stuff, and have a basic version...

feel free to play with it, or join Repl.It .. and fork this to make your own.

Free SL Database Test

the basic LSL scripts for testing are...

// to add to a database...

string myName;
string myId;
key my_reqKey;
string addCustomer = "https://SecondLife-NEDB-01.xiija.repl.co/api/db/input";
default
{
    state_entry()
    {  myId   = "f216c381-8e1d-46ba-8861-d4811f0bdbc5";
       myName = "Skywalker Scofield";
       //myId = llGetOwner();
       //myName = llKey2Name( myId );       
    }
    touch_start(integer total_number)
    {
      string j_obj = llList2Json( JSON_OBJECT,     
       [ "name",    myName,
         "cust_id", myId
       ]);  
           
      my_reqKey =  llHTTPRequest( addCustomer , 
       [ HTTP_USER_AGENT, "XML-Getter/1.0 (Mozilla Compatible)", 
         HTTP_METHOD, "POST", 
         HTTP_MIMETYPE, "application/json", 
         HTTP_BODY_MAXLENGTH,16384,
         HTTP_PRAGMA_NO_CACHE,TRUE
       ], j_obj);       
       llOwnerSay("sending...");    
    }
    http_response(key request_id, integer status, list metadata, string body)
    {  if (request_id !=  my_reqKey ) return;// exit if unknown
       if(status != 200) {llSay(0,"Unable to get page" + "\nSTATUS: " + (string)status);return;} 
       
       llOwnerSay("Body: \n" + body);
    }
}

to get the info from the database...

string myName;
string myId;
key my_reqKey;
string getCustomer = "https://SecondLife-NEDB-01.xiija.repl.co/api/db/output"; 
default
{
    state_entry()
    {  // myId   = "f216c381-8e1d-46ba-8861-d4811f0bdbc5";
       // myName = "Skywalker Scofield";
       myId   = llGetOwner();
       myName = llKey2Name( myId );
       
    }
    touch_start(integer total_number)
    {    
      my_reqKey =  llHTTPRequest( getCustomer , 
       [ HTTP_USER_AGENT, "XML-Getter/1.0 (Mozilla Compatible)", 
         HTTP_METHOD, "GET", 
         HTTP_MIMETYPE, "application/json", 
         HTTP_BODY_MAXLENGTH,16384,
         HTTP_PRAGMA_NO_CACHE,TRUE
       ],"");       
       llOwnerSay("getting...");    
    }
    http_response(key request_id, integer status, list metadata, string body)
    {  if (request_id !=  my_reqKey ) return;// exit if unknown
       if(status != 200) {llSay(0,"Unable to get page" + "\nSTATUS: " + (string)status);return;} 
       
       list infoz  = llJson2List( body );
       integer len = llGetListLength( infoz );      
       integer x;
       for(; x < len;++x)
       {  llOwnerSay( "\n Customer Name: " +  llJsonGetValue( body, [x, "name" ] ) + "\n" ); // or  llJsonGetValue( body, [x, "cust_id" ] )
       }
    }
}

i was trying to get radio station info from a SomaFM json feed, here...

https://api.somafm.com/channels.json

but it seems LSL can't parse tabs or newlines? ..

or at least, i couldn't figure out how to do that..

I was trying this on the SomaFM json file...

 http_response(key k,integer status, list meta, string body)   
    {   if(status != 200) {llSay(0,"Unable to get page" + "\nSTATUS: " + (string)status);return;}  
        
        if(k ==  http_request_id)
        {     llOwnerSay( "\n INFO IS: " +  llJsonGetValue( body, [ "channels", 0, "title" ] ) + "\n" );
        }
    }

 

but it didn't work on the soma json :(

tested with some psuedo-code and it worked fine...

  string body = "{\"mansBestFriend\":[  {\"dog\":\"fido\"},  {\"dog\":\"spot\"} ]   }";
  llSay(0, llJsonGetValue( body, ["mansBestFriend",1,"dog"]));//returns "spot" in localchat

so it's either the tabs or newlines.. or both?

Any ideas?

Edited by Xiija
  • Thanks 1
Link to comment
Share on other sites

is what Nova said

a way to see that is an incomplete JSON record, that tab and linefeed chars are parsed as they should be, and a way to fix this JSON record
 

http_response(key request_id, integer status, list metadata, string body)
{     
	if (request_id !=  my_reqKey ) return;// exit if unknown
    if(status != 200) {llSay(0,"Unable to get page" + "\nSTATUS: " + (string)status);return;}
              
    // find the "lastPlaying" tag of the 1st station record
    integer i = llSubStringIndex(body, "\"lastPlaying\":") - 1;
    // find the closing brace of "lastPlaying"
    integer j = llSubStringIndex(llDeleteSubString(body, 0, i), "}");      
    // strip off any additional chars and close the string with proper JSON ending
    body = llDeleteSubString(body, i + j, -1) + "}]}";

    llOwnerSay("Station name is: " + llJsonGetValue(body, ["channels", 0, "title"]));
    llOwnerSay("Last playing is: " + llJsonGetValue(body, ["channels", 0, "lastPlaying"]));
}

 

 

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1254 days.

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
 Share

×
×
  • Create New...