Quantcast
Channel: Kodi Community Forum - All Forums
Viewing all articles
Browse latest Browse all 84005

[PY] Best way to read JSON response?

$
0
0
I'd like your opinion on the most efficient way to handle a json response in py. All I'm trying to do is use JSON to get the XBMC movie IDs for a series of IMDB numbers, but in the absence of any JSON filters I need to dump the whole thing to a string (quite quick) then turn it into a massive searchable tuple (very slow). JSON is my alternative to using sql to connect to the db - I quite like not being dependent on db type or location.

Code:
import re, simplejson, xbmc, jsonrpclib
jsonurl='{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies","params": {"properties" : ["tag","imdbnumber"], "sort": { "order": "ascending", "method": "label", "ignorearticle": true } }, "id": "libMovies"}'
jsonresponse=simplejson.loads(xbmc.executeJSONRPC(jsonurl))
xbmcdbtuple = re.findall(r'imdbnumber\': u\'(.+?)\', u\'tag\': \[(.+?)\]\', u\'movieid\': (.+?), u\'label\': \'(.+?)\'', data)

This cannot be the smartest way to go about things - ideas?

Viewing all articles
Browse latest Browse all 84005

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>