Back with another question - JSON query
#1
I am busy finilising my addon/script, and one thing that i would love to add, is for it to test if a specific show is in progress (tv show in progress, some episodes watched, not episode in progress, half way watched.)

this is a snippet of the code:

Code:
while item_count < item_count_max:
            show = shows_list[random.randint(0, len(shows_list) - 1)]
            
            if show['watchedepisodes'] < show['episode'] and show['tvshowid'] not in IGNORE
                Do a few things

Now, i would like to bring in another if statement before "if show[watchedepisodes] ..." ranging somthing like:
Code:
if show[inprogress] = true
   if show[watchedepisodes] ...

Any help, suggestions, or documents to read?
Reply
#2
I don't understand your question: it's about 'if' syntax ? or it's about how to load json data?

For json data:

Code:
import urllib2
import json

def loadJsonFromUrl (url):
    data = None
    try:
        response = urllib2.urlopen(url)
        data = json.load(response)
    except:
        pass
    return data

Then Json data is fully accessible using array notation like

Code:
json = loadJsonFromUrl("http://www......")
regions = json["nations"]["italy"]["regions"]
for region in regions
    print region["name"]

...
Reply

Logout Mark Read Team Forum Stats Members Help
Back with another question - JSON query0