2011-09-01, 22:58
I'm hoping someone can help with what I suspect is a fairly simple problem.
I've written a script that plays a random movie from the user's library. It works fine on my machine, but a user has said it's throwing up an error when he runs it.
The error is:
This to me looks like simplejson can't decode the json result which contains a letter with an accent (I think it's "ö").
Is there something I need to do in the script for it to handle the json result correctly?
For info, the line in the code is:
This is nightly version of xbmc running on Win7.
As said, it runs fine on my system so I suspect the error is related to the use of accented letters.
Thanks.
I've written a script that plays a random movie from the user's library. It works fine on my machine, but a user has said it's throwing up an error when he runs it.
The error is:
Code:
16:03:02 T:2604 ERROR: Error Type: <type 'exceptions.UnicodeDecodeError'>
16:03:02 T:2604 ERROR: Error Contents: 'utf8' codec can't decode byte 0xf6 in position 3: invalid start byte
16:03:02 T:2260 DEBUG: Error: Requested setting (pvrmanager.enabled) was not found. It must be case-sensitive
16:03:02 T:2604 ERROR: Traceback (most recent call last):
File "C:\Users\xbmc\AppData\Roaming\XBMC\addons\script.randommovie\default.py", line 121, in <module>
moviesJSON = getMovieLibrary()
File "C:\Users\xbmc\AppData\Roaming\XBMC\addons\script.randommovie\default.py", line 33, in getMovieLibrary
movies = json.loads(xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "fields": ["genre", "playcount", "file"]}, "id": 1}'))
File "C:\Users\xbmc\AppData\Roaming\XBMC\addons\script.module.simplejson\lib\simplejson\__init__.py", line 307, in loads
return _default_decoder.decode(s)
File "C:\Users\xbmc\AppData\Roaming\XBMC\addons\script.module.simplejson\lib\simplejson\decoder.py", line 335, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\xbmc\AppData\Roaming\XBMC\addons\script.module.simplejson\lib\simplejson\decoder.py", line 351, in raw_decode
obj, end = self.scan_once(s, idx)
File "C:\Users\xbmc\AppData\Roaming\XBMC\addons\script.module.simplejson\lib\simplejson\scanner.py", line 36, in _scan_once
return parse_object((string, idx + 1), encoding, strict, _scan_once, object_hook)
File "C:\Users\xbmc\AppData\Roaming\XBMC\addons\script.module.simplejson\lib\simplejson\decoder.py", line 185, in JSONObject
value, end = scan_once(s, end)
File "C:\Users\xbmc\AppData\Roaming\XBMC\addons\script.module.simplejson\lib\simplejson\scanner.py", line 36, in _scan_once
return parse_object((string, idx + 1), encoding, strict, _scan_once, object_hook)
File "C:\Users\xbmc\AppData\Roaming\XBMC\addons\script.module.simplejson\lib\simplejson\decoder.py", line 185, in JSONObject
value, end = scan_once(s, end)
File "C:\Users\xbmc\AppData\Roaming\XBMC\addons\script.module.simplejson\lib\simplejson\scanner.py", line 38, in _scan_once
return parse_array((string, idx + 1), _scan_once)
File "C:\Users\xbmc\AppData\Roaming\XBMC\addons\script.module.simplejson\lib\simplejson\decoder.py", line 235, in JSONArray
value, end = scan_once(s, end)
File "C:\Users\xbmc\AppData\Roaming\XBMC\addons\script.module.simplejson\lib\simplejson\scanner.py", line 36, in _scan_once
return parse_object((string, idx + 1), encoding, strict, _scan_once, object_hook)
File "C:\Users\xbmc\AppData\Roaming\XBMC\addons\script.module.simplejson\lib\simplejson\decoder.py", line 185, in JSONObject
value, end = scan_once(s, end)
File "C:\Users\xbmc\AppData\Roaming\XBMC\addons\script.module.simplejson\lib\simplejson\scanner.py", line 34, in _scan_once
return parse_string(string, idx + 1, encoding, strict)
File "C:\Users\xbmc\AppData\Roaming\XBMC\addons\script.module.simplejson\lib\simplejson\decoder.py", line 89, in py_scanstring
content = unicode(content, encoding)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xf6 in position 3: invalid start byte
This to me looks like simplejson can't decode the json result which contains a letter with an accent (I think it's "ö").
Is there something I need to do in the script for it to handle the json result correctly?
For info, the line in the code is:
Code:
def getMovieLibrary():
# get the raw JSON output
movies = json.loads(xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "fields": ["genre", "playcount", "file"]}, "id": 1}'))
# and return it
return movies
This is nightly version of xbmc running on Win7.
As said, it runs fine on my system so I suspect the error is related to the use of accented letters.
Thanks.