Your 2nd Add-On: Online Videos!
#75
Horray,

finally figured out what was wrong - it works now!

html = requests.get(url)
VIDEOS = json.loads(html.content)

NOTE:
To be able load utf8 JSON file from a web server it requires to install 'script.modules.requests-2.22.zip' from zip file.

Then  add into 'addon.xml' file '<import addon="script.module.requests" version="2.22.0"/>'

<requires>
  ......
  <import addon="script.module.requests" version="2.22.0"/>
</requires>

At this stage KODI will complain about utf8 values in the hash. Values will require encoding which can be achieved as following

import json
import requests

url = 'http://iptv.server.com/series.json'

VIDEOS = {}
html = requests.get(url)
DATA = json.loads(html.content)

for v in DATA.keys():
    s = v.encode('utf-8')
    #xbmc.log(s, xbmc.LOGNOTICE)
    VIDEOS[s] = []
    for v in DATA[v]:
        name = v['name'].encode('utf-8')
        genre = v['genre'].encode('utf-8')
        #xbmc.log(name, xbmc.LOGNOTICE)
        #xbmc.log(genre, xbmc.LOGNOTICE)
        e = { "name": name, "thumb": v["thumb"], "video": v["video"], "genre": genre }
        VIDEOS[s].append(e)

Provided in hope that somebody will find it useful.
Reply


Messages In This Thread
Your 2nd Add-On: Online Videos! - by zag - 2015-11-20, 15:28
RE: Your 2nd Add-On: Online Videos! - by zag - 2015-11-20, 15:33
RE: Your 2nd Add-On: Online Videos! - by zag - 2015-11-30, 14:42
RE: Your 2nd Add-On: Online Videos! - by zag - 2015-12-01, 12:58
RE: Your 2nd Add-On: Online Videos! - by zag - 2016-01-18, 14:37
RE: Your 2nd Add-On: Online Videos! - by Polar Bear - 2020-05-12, 07:36
RE: Your 2nd Add-On: Online Videos! - by pa79 - 2020-09-09, 19:59
Logout Mark Read Team Forum Stats Members Help
Your 2nd Add-On: Online Videos!2