Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Original thread:
Post 25 made on Wednesday August 5, 2020 at 17:51
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,996
Note that I have added left/right brackets added around http preamble to prevent RC from trying to download the actual URLs :-).

Example 11.3 in the Dev Guide assumes that the image url is:

[http://]MyServer.com/images/img1.jpg

You can take the URL data you get from KODI (example you posted) and then all decodeURI(urlText) to get the URL that you need to request in human-readable terms.

[Link: w3schools.com]


Next, you need to do an HTTP Get Request to

[http://]image.tmdb.org/t/p/original/579HAFLpODEC9Reb64wbCHSUi4O.jpg

You do this in the same way you submit 'GET' requests to KODI...

Instead of a socket IP address, you pass in 'image.tmdb.org' for the host/ip and the port number is 80 to your socket constructor.

The actual line you use to request the image is the path part of the URL which starts after the first '/' following the host.

In this case your string would be:

'GET /t/p/original/579HAFLpODEC9Reb64wbCHSUi4O.jpg /HTTP1.0\r\n\r\n'

The actual response payload (imageStartIndex) indicates the position of the delimiter of the HTTP Response Header and body. In order to take the response data you have to move past the '\r\n\r\n' to get to the start of the image data which is imageStartIndex + 4.

The example you supplied is erroneously trying to create an image with a string that starts with '\r\n\r\n' and has the number '4' appended to the end. (adding integer 4 to a string results in concatenating '4'). As the string does not start with 'JPEG' or whatever the preamble for the actual image data is but insteads starts with '\r\n\r\n', that's the cause of your issue.

Make this change along with decoding the URI as I called out above and I think you'll see different results that actually work.


// remove the HTTP information from the received data
var imageStartIndex = cover.indexOf("\r\n\r\n");
var bitmapData = cover.substring(imageStartIndex+4);
// make and display the image
var MyImage = new Image(bitmapData);
widget(“MOVIE_COVER”).setImage(MyImage);

Last edited by Lyndel McGee on August 5, 2020 18:12.
Lyndel McGee
Philips Pronto Addict/Beta Tester


Hosting Services by ipHouse