Kodi library image:// url doesnt work without encoding for plugin listitem
#1
Im trying to add some data from a library item to a plugin listitem and after retrieving the artwork using the JSONRPC request i have had to encode the image url and put in my login details in order to get it to successfully load in the plugin.

So for example the artwork is being returned from the tvshowid via json RPC and comes back in the format like:

image://%2fhome%2f.kodi%2fuserdata%2faddon_data%2fplugin.video.somevideoplugin%2fTVShows%2f311711%2ffanart.jpg/

Initially i was just adding that within the fanart listitem property, as I would for a normal URL from tvdb or tmdb but that wouldn't actually load the image:// URL and i got nothing but grey boxes.

To get it to work I've had to strip off the trailing "/" then encode the image url "image://...." eg urllib.quote_plus(str('image://fkjhjkfhf...')[:-1]) and further i've had to append that to a url string containing my kodi login and port details before the image could be retrieved:

http://USERNAME:[email protected]:XXXX/image/ + urllib.quote_plus(str('image://fkjhjkfhf...')[:-1])

So i've got it to work, however should i not be able to reference the library images directly within the plugin?
Or if not directly can they not be loaded as a special path so you don't need to provide authentication or port details?

Ive tried searching but searching for image:// url kodi isnt really useful and the docs are not too useful either in this regard (and actually wrong, i had to inspect the kodi web interface before i could figure out the correct url).
Reply
#2
That's expected.

Use xbmc.translatpath() instead to pass the real location of the file.
Reply
#3
(2020-07-11, 15:19)sarbes Wrote: That's expected.

Use xbmc.translatpath() instead to pass the real location of the file.

Yeah i was doing some googling and I came across the xbmc.translatepath() reference and i remembered that I had used it before to convert a special:// path in another addon previously, but that was after i had made my post. Thanks for coming back anyway.

I haven't tested it with an image:// url yet as the addon dev came back to me with a commit which fixed the problem (and it was actually already working but i had the addon setting disabled, doh) but i figured there must have be a way to do it, presumably based on my hazy recollections.

So i'll get around to testing it and post back an explicit confirmation (i like for this sort of stuff to be searchable because i've had too many problems referenced in forum threads to which people post pointers for the OP never to confirm how they fixed the problem or if they did to then not post the actual specific and explicit resolution steps. My problem might not be exactly the same but knowing the kind of things which actually work is often half the battle).
Reply
#4
(2020-07-11, 15:49)henryjfry Wrote:
(2020-07-11, 15:19)sarbes Wrote: That's expected.

Use xbmc.translatpath() instead to pass the real location of the file.

Yeah i was doing some googling and I came across the xbmc.translatepath() reference and i remembered that I had used it before to convert a special:// path in another addon previously, but that was after i had made my post. Thanks for coming back anyway.

I haven't tested it with an image:// url yet as the addon dev came back to me with a commit which fixed the problem (and it was actually already working but i had the addon setting disabled, doh) but i figured there must have be a way to do it, presumably based on my hazy recollections.

So i'll get around to testing it and post back an explicit confirmation (i like for this sort of stuff to be searchable because i've had too many problems referenced in forum threads to which people post pointers for the OP never to confirm how they fixed the problem or if they did to then not post the actual specific and explicit resolution steps. My problem might not be exactly the same but knowing the kind of things which actually work is often half the battle).
So whatever I was doing it appears that you do not need to translatepath for the image:// url which kodi returns.
I think the wiki threw me and I was trying to decode the urls, which needed more steps.

However within the addon just returning the native image:// url with all the url encoding included was sufficient for the images to be added to the listitem.
I had thought I was doing that at the beginning and it wasn't working, which was when i then went down the route of trying to open the image urls in my browser which wouldn't work until i had the externally accessible link.
But I think i may have started by stripping off the training "/" thinking that the url wouldn't work and that lead me down the garden path.

So i can report that when kodi jsonrpc returns a url encoded image url referencing the file path to a library image you can just use that as is.
No translatepath or further url encoding/decoding required.

You only need to go down that route to access the images externally, ie via the kodi webserver.




Code:

            import json
            kodi_params = ('{"jsonrpc": "2.0", "params": {"sort": {"order": "ascending", "method": "title"}, "filter": {"operator": "is", "field": "title", "value": "'+tvshowtitle+'"}, "properties": []}, "method": "VideoLibrary.GetTVShows", "id": 1}')
            json_result = xbmc.executeJSONRPC(kodi_params)
            json_object = json.loads(json_result)

            try:
                    tvshow_id = json_object['result']['tvshows'][0]['tvshowid']
            except:
                tvshow_id = None
            if tvshow_id <> None:
                kodi_params = ('{"jsonrpc":"2.0","method":"VideoLibrary.GetTVShowDetails","params": {"tvshowid": '+str(tvshow_id)+', "properties": ["art"]},"id":1}')
                json_result = xbmc.executeJSONRPC(str(kodi_params))
                json_object = json.loads(json_result)
                lib_fanart = json_object['result']['tvshowdetails']['art']['fanart']
                lib_poster = json_object['result']['tvshowdetails']['art']['poster']
                lib_clearlogo = json_object['result']['tvshowdetails']['art']['clearlogo']
                lib_clearart = json_object['result']['tvshowdetails']['art']['clearart']
                lib_banner = json_object['result']['tvshowdetails']['art']['banner']
                lib_landscape = json_object['result']['tvshowdetails']['art']['landscape']

Reply



Logout Mark Read Team Forum Stats Members Help
Kodi library image:// url doesnt work without encoding for plugin listitem0
This forum uses Lukasz Tkacz MyBB addons.