v15 Getting thumbnail from JSON-RPC issues
#1
Hey guys, i`m having a small issue regarding retrieving posters, fanart etc. via the JSON RPC and the URL encode method.

So the response from the JSON server looks something like this :

Code:
{"id":"libMovies","jsonrpc":"2.0","result":{"limits":{"end":1,"start":0,"total":1},"movies":[{"art":{"fanart":"image://http%3a%2f%2fimage.tmdb.org%2ft%2fp%2foriginal%2f1O3tFuQsVgmjwx47xGKBjkSUiU6.jpg/","poster":"image://http%3a%2f%2fimage.tmdb.org%2ft%2fp%2foriginal%2fuVEFQvFMMsg4e6yb03xOfVsDz4o.jpg/"},"file":"D:\\Media\\Big_Buck_Bunny_1080p.mp4","label":"Big Buck Bunny","movieid":1,"thumbnail":"image://http%3a%2f%2fimage.tmdb.org%2ft%2fp%2foriginal%2fuVEFQvFMMsg4e6yb03xOfVsDz4o.jpg/"}]}}

So according to the Wiki, i should be using a syntax like this to retrieve the images

Code:
http://192.168.1.116/image/url_encode(URL_FROM_THE_JSON_RESPONSE)

So, for example, for the fanart, it should be like this :

Code:
http://192.168.1.116/image/url_encode(image://http%3a%2f%2fimage.tmdb.org%2ft%2fp%2foriginal%2f1O3tFuQsVgmjwx47xGKBjkSUiU6.jpg/)

But all i get is a file not found error in Chrome when attempting to use the syntax. Same for poster,thumbnail etc.
Am i missing something?
Reply
#2
You need to call the JSON http method Files.PrepareDownload with the artwork url as a parameter, then download the resulting "prepared" url (the "path").

For instance:
Code:
ARTWORK: "image://nfs%3a%2f%2f192.168.0.3%2fmnt%2fshare%2fmedia%2fVideo%2fMoviesHD%2fZombieland%20(2009)%5bBDRip%5d-poster.jpg/"
                                                      
JSON WEB REQUEST: {"jsonrpc": "2.0", "params": {"path": "image://nfs%3a%2f%2f192.168.0.3%2fmnt%2fshare%2fmedia%2fVideo%2fMoviesHD%2fZombieland%20(2009)%5bBDRip%5d-poster.jpg/"}, "method": "Files.PrepareDownload", "id": "preparedl"}                                                                                                      

RECEIVED DATA: {"id":"preparedl","jsonrpc":"2.0","result":{"details":{"path":"image/image%3a%2f%2fnfs%253a%252f%252f192.168.0.3%252fmnt%252fshare%252fmedia%252fVideo%252fMoviesHD%252fZombieland%2520(2009)%255bBDRip%255d-poster.jpg%2f"},"mode":"redirect","protocol":"http"}}

Now you can download "path" from the Kodi webserver and you should have your artwork.
Code:
http://192.168.1.116/image/image%3a%2f%2fnfs%253a%252f%252f192.168.0.3%252fmnt%252fshare%252fmedia%252fVideo%252fMoviesHD%252fZombieland%2520(2009)%255bBDRip%255d-poster.jpg%2f
Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
Reply
#3
Thanks a lot for the reply. Unfortunately i`m still facing an issue.

So for example for this image URL :
Code:
image://http%3a%2f%2fimage.tmdb.org%2ft%2fp%2foriginal%2fuVEFQvFMMsg4e6yb03xOfVsDz4o.jpg/
I used the Files.PrepareDownload method like this

Code:
http://192.168.1.116/jsonrpc?request={"jsonrpc": "2.0", "params": {"path": "image://http%3a%2f%2fimage.tmdb.org%2ft%2fp%2foriginal%2fuVEFQvFMMsg4e6yb03xOfVsDz4o.jpg/"}, "method": "Files.PrepareDownload", "id": "preparedl"}

But i get an error code :

Code:
{"error":{"code":-32602,"data":{"details":null},"message":"Invalid params."},"id":"preparedl","jsonrpc":"2.0"}

So i searched in the JSON Wiki page for the Files.PrepareDownload method to check if there is any additional parameters i need to add, but only found File.Download (http://kodi.wiki/view/JSON-RPC_API/v3#Files.Download) where the only parameter seems to be the path, like in your example. Also tried with Files.Download and get a method not found error..
Reply
#4
Works fine...
Code:
$ curl -d '{"jsonrpc": "2.0", "params": {"path": "image://nfs%3a%2f%2f192.168.0.3%2fmnt%2fshare%2fmedia%2fVideo%2fMoviesHD%2fZombieland%20(2009)%5bBDRip%5d-poster.jpg/"}, "method": "Files.PrepareDownload", "id": "preparedl"}' -H "content-type:application/json" http://192.168.0.12:8080/jsonrpc
{"id":"preparedl","jsonrpc":"2.0","result":{"details":{"path":"image/image%3a%2f%2fnfs%253a%252f%252f192.168.0.3%252fmnt%252fshare%252fmedia%252fVideo%252fMoviesHD%252fZombieland%2520(2009)%255bBDRip%255d-poster.jpg%2f"},"mode":"redirect","protocol":"http"}}
You need to POST the request data to the web server, along with the correct content type. Once you have the path, a regular GET request will be sufficient to download the artwork.
Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
Reply
#5
Well, it worked, eventually, some weird stuff happend. First i i tried using curl, with this code

Code:
curl -i -X POST -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0", "params": {"path": "image://nfs%3a%2f%2f192.168.0.3%2fmnt%2fshare%2fmedia%2fVideo%2fMoviesHD%2fZombieland%20​(2009)%5bBDRip%5d-poster.jpg/"}, "method": "Files.PrepareDownload", "id": "preparedl"}' http://192.168.1.116/jsonrpc

"could not resolve host" errors popped out. Tried again with an extension for Chrome (Postman) to send a POST request. "Parse error" message. So gave up and just tried it in my application (Android Java app) that i am writing using the JSON API, and behold, working like a charm, encoded URL is returned, image displayed, fine and dandy. I have no clue why curl and postman are throwing those errors, i`ll investigate after i get some sleep.

Thanks a lot for the advice and have a nice day (or night, depending on what timezone you are in).
Reply
#6
I have the same problem as Soulbind.

I only have a websocket connection so it should be enough to send the following command:
Code:
{"jsonrpc": "2.0", "params": {"path": "image://http%3a%2f%2fimage.tmdb.org%2ft%2fp%2foriginal%2fhDyRQTxiaE2Fbe2r0c3ekM6eRSX.jpg/"}, "method": "Files.PrepareDownload", "id": 410}

I always get the response:
Code:
{"error":{"code":-32601,"message":"Method not found."},"id":410,"jsonrpc":"2.0"}

Also when I try the same directly in a browser:
Code:
http://ipadress:8080/jsonrpc?request={"jsonrpc": "2.0", "params": {"path": "image://http%3a%2f%2fimage.tmdb.org%2ft%2fp%2foriginal%2fhDyRQTxiaE2Fbe2r0c3ekM6eRSX.jpg/"}, "method": "Files.PrepareDownload", "id": 410}
I get the same error. I don't understand what happens here.

Apparently it is necessary to use preparedownload because not all thumbnails are accessible by replacing "image://" with "http://ipadress:8080/image/" followed by the image file name.

Edit
The most strange thing is that if you try yo open an image by opening the link:
http://ipadress:8080/image/http%3a%2f%2f...M6eRSX.jpg
That some of the covers will load and a lot of the covers give "file not found". I think this is strange because the cover is returned by JSON but then you can not open the exact link.
Reply
#7
I am having a new related problem:
When I update a cover i get the wrong cover back as a thumbnail.
To fetch the covers i use the following method:
Code:
{"jsonrpc":"2.0","method":"VideoLibrary.GetMovieDetails","params":{"movieid":20,"properties":["thumbnail"]},"id":2}

This results in the cover string. In my case:
Code:
image://http%3a%2f%2f172.16.63.31%3a8096%2femby%2fItems%2ff702bdc264c8cb272a77390cd6596180%2fImages%2fPrimary%2f0%3fMaxWidth%3d10000%26MaxHeight%3d10000%26Format%3doriginal%26Tag%3d5194b09b9b665a60fe92bd03688068d6

From this string i remove the information which results in the following string:
Code:
image://http%3a%2f%2f172.16.63.31%3a8096%2femby%2fItems%2ff702bdc264c8cb272a77390cd6596180%2fImages%2fPrimary%2f0%3f

Then I URL encode the string resulting (This is necessary for Kodi to push a thumbnail):
Code:
image%3A%2F%2Fhttp%253a%252f%252f172.16.63.31%253a8096%252femby%252fItems%252ff702bdc264c8cb272a77390cd6596180%252fImages%252fPrimary%252f0%253f

And as a last step I add the path of the Kodi client so my tablet can reach it:
Code:
http://172.16.63.163:8080/image/image%3A%2F%2Fhttp%253a%252f%252f172.16.63.31%253a8096%252femby%252fItems%252ff702bdc264c8cb272a77390cd6596180%252fImages%252fPrimary%252f0%253f

This all works fine but now I am getting the wrong cover image on my tablet while Kodi is displaying the correct one within the movie information page.

I took a look in the kodi database in table "art" and here is file name is exactly the same as the one i get in return.
Am i doing something wrong or is this a "error" in Kodi. I am using Kodi 16.1
Reply

Logout Mark Read Team Forum Stats Members Help
Getting thumbnail from JSON-RPC issues0