2021-05-13, 09:44
Hi there!
I have an add-on that I have been working on, to convert from Python 2, and it is almost working with Kodi 19, but I am suck on one line... I think the one line, anyways. I am not a developer, nor am I that familiar with Python 3 :-) I just plodded through, using errors and google searches to get the add-on to work up to this point.
The code chunk is:
json_query = \
xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "VideoLibrary.Clean","id": 1 }'
json_query = unicode(json_query, 'utf-8', errors='ignore') ##<-- This line is offending line
json_query = jsoninterface.loads(json_query)
if json_query.has_key('result'):
dbglog('Clean library sucessfully called')
Now I know that Python 3, you use str instead of unicode, since the queries are all encoded. However, when I do that and use
json_query = str(json_query, 'utf-8', errors='ignore')
I get the error:
json_query = str(json_query, 'utf-8', errors='ignore')
TypeError: decoding str is not supported
If I remove the offending line completely, I get the following error:
if json_query.has_key('result'):
AttributeError: 'dict' object has no attribute 'has_key'
-->End of Python script error report<--
Any help would be appreciated. The full code base cane be seen here:
https://pastebin.com/YxMC6sw7
Thanks!
Ken
I have an add-on that I have been working on, to convert from Python 2, and it is almost working with Kodi 19, but I am suck on one line... I think the one line, anyways. I am not a developer, nor am I that familiar with Python 3 :-) I just plodded through, using errors and google searches to get the add-on to work up to this point.
The code chunk is:
json_query = \
xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "VideoLibrary.Clean","id": 1 }'
json_query = unicode(json_query, 'utf-8', errors='ignore') ##<-- This line is offending line
json_query = jsoninterface.loads(json_query)
if json_query.has_key('result'):
dbglog('Clean library sucessfully called')
Now I know that Python 3, you use str instead of unicode, since the queries are all encoded. However, when I do that and use
json_query = str(json_query, 'utf-8', errors='ignore')
I get the error:
json_query = str(json_query, 'utf-8', errors='ignore')
TypeError: decoding str is not supported
If I remove the offending line completely, I get the following error:
if json_query.has_key('result'):
AttributeError: 'dict' object has no attribute 'has_key'
-->End of Python script error report<--
Any help would be appreciated. The full code base cane be seen here:
https://pastebin.com/YxMC6sw7
Thanks!
Ken