Difference between revisions of "Talk:LibraryDisplayLandScreenshot"

From Second Life Wiki
Jump to navigation Jump to search
Line 5: Line 5:


::: and bibbidi-bobbidi-boo! {{Jira|BUG-6151}} --[[User:Cerise Sorbet|Cerise Sorbet]] 19:47, 24 May 2014 (PDT)
::: and bibbidi-bobbidi-boo! {{Jira|BUG-6151}} --[[User:Cerise Sorbet|Cerise Sorbet]] 19:47, 24 May 2014 (PDT)
::::
Below should work :
<lsl>
// Credit goes to Jana Kamachi/Solar Alter
// for discovering this concept first
// and taking it beyond just displaying the profile picture
// see http://forums.secondlife.com/showthread.php?t=225460
// and https://wiki.secondlife.com/wiki/User:Jana_Kamachi/Profile
// for further information
/*
    Modified by Jon Desmoulins to use the new PARCEL_DETAILS_ID
    to fetch the image that displays on the world.secondlife.com pages
    It's a little hacky, but it works.
*/
string gLandUrl = "http://world.secondlife.com/place/";  //Base URL for world search
ResetTextures()
{
    llSetTexture(TEXTURE_BLANK, ALL_SIDES);
}
default
{
    state_entry()
    {
        ResetTextures();
    }
    touch_start(integer num_detected)
    {
        string parcelID = (string)llList2Key(llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_ID]), 0);
        string worlURL = gLandUrl + parcelID;
       
        string requestYQL = llEscapeURL("select src from html where url=\"")  + worlURL + llEscapeURL("\"" ) + llEscapeURL(" and xpath='//img[@class=\"parcelimg\"]'");
        string requestREST = "http://query.yahooapis.com/v1/public/yql?q=" + (requestYQL) +  "&format=json&callback=";
                   
        llHTTPRequest(requestREST, [], "");       
    }
    on_rez(integer start_param)
    {
        ResetTextures();
    }
    http_response(key request_id,integer status, list metadata, string body)
    {
        if (status == 200)
        {
            string urlImage =  llJsonGetValue ( body, [ "query" , "results" , "img", "src" ] );
           
            if ( urlImage != JSON_INVALID )
            {
                key UUIDImage = (key)llGetSubString(urlImage, -38, -3 );
               
               
                if ( UUIDImage != NULL_KEY )
                {
                    llOwnerSay("Found parcel image " + (string)UUIDImage);
                    llSetTexture(UUIDImage, ALL_SIDES);
                }
            }
            else
            {
                llOwnerSay("Could not retrieve parcel page, parcel not found");
                ResetTextures();     
            }     
        }
        else if ( status == 400 )
        {
            llOwnerSay("Could not retrieve parcel page, error YQL");
            if ( llJsonValueType ( body, [ "error" , "description"] )  == JSON_STRING )
            {
                llOwnerSay(  llJsonGetValue ( body, [ "error" , "description" ] ));
            }           
            ResetTextures();
        }
        else
        {
            llOwnerSay("Could not retrieve parcel page, error HTTP");
            llOwnerSay(llList2CSV(["Error HTTP", status]));
            ResetTextures();
        }
    }
}
</lsl>
[[User:Miranda Umino|Miranda Umino]] 20:15, 28 May 2014 (PDT)

Revision as of 20:15, 28 May 2014

This script seems to be no longer working since the page it accesses has been altered to a point that the script can no longer handle the change. —The preceding unsigned comment was added on 03:43, 24 May 2014 by Fritigern Gothly

Yep, looks pretty dead. The imageid meta tag is toast, and all the added banner gunk pushes the <img> tag past 16K. User-agent spoofing almost looked like it would save the day, but the banner gunk is still there, just hidden. --Cerise Sorbet 17:57, 24 May 2014 (PDT)
I came to the same conclusion. I'd say open a new JIRA for this. -- Strife (talk|contribs) 18:37, 24 May 2014 (PDT)
and bibbidi-bobbidi-boo! BUG-6151 --Cerise Sorbet 19:47, 24 May 2014 (PDT)

Below should work : <lsl> // Credit goes to Jana Kamachi/Solar Alter // for discovering this concept first // and taking it beyond just displaying the profile picture // see http://forums.secondlife.com/showthread.php?t=225460 // and https://wiki.secondlife.com/wiki/User:Jana_Kamachi/Profile // for further information

/*

   Modified by Jon Desmoulins to use the new PARCEL_DETAILS_ID
   to fetch the image that displays on the world.secondlife.com pages
   It's a little hacky, but it works.
  • /


string gLandUrl = "http://world.secondlife.com/place/"; //Base URL for world search


ResetTextures() {

   llSetTexture(TEXTURE_BLANK, ALL_SIDES);

}

default {

   state_entry()
   {
       ResetTextures();
   }

   touch_start(integer num_detected)
   {
       string parcelID = (string)llList2Key(llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_ID]), 0);
       string worlURL = gLandUrl + parcelID;
       
       string requestYQL = llEscapeURL("select src from html where url=\"")  + worlURL + llEscapeURL("\"" ) + llEscapeURL(" and xpath='//img[@class=\"parcelimg\"]'");
       string requestREST = "http://query.yahooapis.com/v1/public/yql?q=" + (requestYQL) +  "&format=json&callback=";

                   
       llHTTPRequest(requestREST, [], "");        
   }

   on_rez(integer start_param)
   {
       ResetTextures();
   }

   http_response(key request_id,integer status, list metadata, string body)
   {
       if (status == 200)
       {
           string urlImage =  llJsonGetValue ( body, [ "query" , "results" , "img", "src" ] );
           
           if ( urlImage != JSON_INVALID )
           { 
               key UUIDImage = (key)llGetSubString(urlImage, -38, -3 );
               
                
               if ( UUIDImage != NULL_KEY )
               {
                   llOwnerSay("Found parcel image " + (string)UUIDImage);
                    llSetTexture(UUIDImage, ALL_SIDES);
               }
           }
           else
           {
               llOwnerSay("Could not retrieve parcel page, parcel not found");
               ResetTextures();      
           }      
       }
       else if ( status == 400 )
       {
           llOwnerSay("Could not retrieve parcel page, error YQL");
           if ( llJsonValueType ( body, [ "error" , "description"] )  == JSON_STRING )
           {
               llOwnerSay(  llJsonGetValue ( body, [ "error" , "description" ] ));
           }            
           ResetTextures();
       }
       else
       {
           llOwnerSay("Could not retrieve parcel page, error HTTP");
           llOwnerSay(llList2CSV(["Error HTTP", status]));
           ResetTextures();
       }
   }

} </lsl> Miranda Umino 20:15, 28 May 2014 (PDT)