Kodi Community Forum

Full Version: Getting channel logos
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey there,

I'd like to get the channels of my kodi setup and present the logos of each channel on a web interface. So I'm basically calling:

PHP Code:
{"jsonrpc""2.0""method""PVR.GetChannels""params": {"channelgroupid" :2,"properties":["channel","channeltype","thumbnail","broadcastnow","broadcastnext"]]} 

And I receive the thumbnails as below:

Quote:"thumbnail": "image://%2fhome%2farch%2flogos%2fenen%2flogos%2frtp1.png/"

Does anyone know how can I use this logo on a webpage? I assume there is some method to serve the path above through http?
I just get lost on the documentation. By inspecting other apps I can't find out any other call appart to the one I posted above.

Thanks in advance
It seems that according to: http://kodi.wiki/view/Webserver

The image should be called this way:

http://<your ip>:<configured port>/image/<url encoded image:// path>
Just for reference, what I was trying to do was to present the logos of my own channels on a webpage. So basically, any json-rpc command would be executed from python (from kodi itself), without knowing anything about the webserver setup. This placed a problem because the json api returns a thumbnail value that can only be retrieved if passed to the webserver. Since the python addon doesn't know anything about the webserver (user,pass,port,etc) it's a no go.

So my solution was to find out first the settings of the webserver by calling getsettings:

PHP Code:
import xbmc,json

#small hack to grab webserver endpoint for texture conversion

webserver_ipaddr xbmc.getIPAddress()
webserver_port ''
webserver_username ''
webserver_password ''
webserver_isenabled False
json_response 
xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Settings.GetSettings","params":{"level":"expert"},"id":25}')
decoded_data json.loads(json_response)
for 
setting in decoded_data["result"]["settings"]:
    if 
setting["id"] == "services.webserver"webserver_isenabled setting["value"]
    if 
setting["id"] == "services.webserverport"webserver_port setting["value"
    if 
setting["id"] == "services.webserverusername"webserver_username setting["value"
    if 
setting["id"] == "services.webserverpassword"webserver_password setting["value"
    
if 
webserver_isenabled:
    if 
webserver_password == '':
        
webserver 'http://'+webserver_ipaddr+':'+str(webserver_port)+'/image/'
    
else:
        
webserver 'http://'+webserver_username+':'+webserver_password+'@'+webserver_ipaddr+':'+str(webserver_port)+'/image/'
else:
    
webserver ""

#Now we have a callable webserver url, get all the logos for groupid 2

json_response xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "PVR.GetChannels", "params": {"channelgroupid" : 2,"properties":["channel","channeltype","thumbnail","broadcastnow","broadcastnext"]}, "id": 1 }')
decoded_data json.loads(json_response)
tvchannel_dict = {}
for 
channel in decoded_data["result"]["channels"]:
    try: 
        if 
webserver != ''tvchannel_dict['thumb'] = webserver urllib.quote(channel["thumbnail"])
        else: 
tvchannel_dict['thumb'] = ""
    
excepttvchannel_dict['thumb'] = "" 

Marked as solved.