2020-05-12, 07:36
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.
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.