Retrieve specific data from JSON Response
#1
Hi guys,

I'm developing an add-on for the first time. The add-on is supposed to use JSON commands to obtain some information from the Kodi library as well as set/change some parameters in it.

I have actually a question related to how retrieve the IMDb id for a TV Show after having received the following JSON Response:

Code:
JSON Response: {"id":1,"jsonrpc":"2.0","result":{"limits":{"end":1,"start":0,"total":1},"tvshows":[{"label":"Stranger Things","mpaa":"TV-14","rating":9,"tvshowid":1,"uniqueid":{"imdb":"tt4574334","tmdb":"66732","tvdb":"305288"},"votes":"262868"}]}}

Basically, which is the code/syntax to save in a local variable (e.g. IMDb_id) the received tt4574334 value? I have tried the following code but the result in IMDb_id is None:

Code:
for item in jSonResponse['result']['tvshows']:
             IMDb_id = item.get('uniqueid[0]')

Thanks for any help...please take into account that I'm just facing JSON and python without any expereince on them... Rolleyes
Light IMDb Ratings Update - Keep updated the IMDb ratings for your movies and TV shows.
In case you found useful my work, feel free to offer me a cappuccino!
Reply
#2
Ok, after several trials, I found the way...at the end it was so obvious...

For who is interested:

Code:
for item in jSonResponse['result']['tvshows']:
             unique_id = item.get('uniqueid')
             imdb_id = unique_id.get('imdb')

The thread can be closed. Thanks.
Light IMDb Ratings Update - Keep updated the IMDb ratings for your movies and TV shows.
In case you found useful my work, feel free to offer me a cappuccino!
Reply

Logout Mark Read Team Forum Stats Members Help
Retrieve specific data from JSON Response0