I have issues that I don't know how to solve with Strings/en.json file, that looks like this:
{
"All": "All",
"No Category": "No Category",
"Preferences": "Preferences"
}
when I try to access L('No Category') in python, whis is what I find in logs:
WARNING (data:186) - Error decoding with simplejson, using demjson instead (this will cause a performance hit) - Expecting object: line 20 column 1 (char 522)
TypeError: Framework.components.localization.LocalString('No Category') is not JSON serializable
@handler(PREFIX, TITLE)
def MainMenu():
empty_group = False
groups_list = []
items_list = []
playlist = Resource.Load(Prefs['playlist'], binary = True)
if playlist <> None:
lines = playlist.splitlines()
for i in range(len(lines) - 1):
line = lines*.strip()
if line.startswith('#EXTINF'):
url = lines[i + 1].strip()
title = line[line.rfind(',') + 1:len(line)].strip()
thumb = GetAttribute(line, 'tvg-logo')
group = GetAttribute(line, 'group-title')
if group == '':
empty_group = True
group = L('No Category')
elif not group in groups_list:
groups_list.append(group)
items_list.append({'url': url, 'title': title, 'thumb': thumb, 'group': group})
items_list.sort(key = lambda dict: dict['title'].lower())
groups_list.sort(key = lambda str: str.lower())
groups_list.insert(0, 'All')
if empty_group:
groups_list.append(L('No Category'))
Full code can be found on github, and funny thing is, everything works, but I get these annoying errors that I would like to get rid of. I also attached full log if needed.
I think the issue is that you’re attempting to pass a localized string as an argument to a function. https://github.com/Cigaras/IPTV.bundle/blob/master/Contents/Code/init.py#L45 All data-types that get passed to functions must be serializable as JSON to be passed via the PMS/plugin framework HTTP-API. A localized string is not serializable as it is actually quite different from a standard string. I think you’ll have better luck handling a simple string and replacing it with a localized version within any function where it gets used. The code may not look as elegant that way but it should work.