- import json
- import urllib2
- import base64
- #config
- base64string = base64.encodestring('username:password')
- apikey= 'apikey'
- username ='username'
- apipath='/user/calendar/shows.json/'
- #funcs
- def user_cal_shows():
- request = urllib2.Request("https://api.trakt.tv/user/calendar/shows.json/" + apikey + "/" + username)
- request.add_header("Authorization", "Basic %s" % base64string)
- return json.load(urllib2.urlopen(request))
- out = user_cal_shows()
- for i in range(len(out)):
- showname = out[i]['episodes'][0]['show']['title'] #Fringe
- ep_name = out[i]['episodes'][0]['episode']['title'] #In Absentia
- network = out[i]['episodes'][0]['show']['network'] #FOX
- airtime = out[i]['episodes'][0]['show']['air_time'] #9:00pm
- season = out[i]['episodes'][0]['episode']['season'] #5
- ep_num = out[i]['episodes'][0]['episode']['number'] #2
- in_watch = out[i]['episodes'][0]['show']['in_watchlist'] #True
- airday = out[i]['episodes'][0]['show']['air_day'] #Friday
- runtime = out[i]['episodes'][0]['show']['runtime'] #60v
- print showname + " airs at " + airtime + " on " + airday
- print "\t " + str(season) + "." + str(ep_num) + " - " + ep_name + " " + network
- print "\t watchlist: " + str(in_watch) + " - runtime: " + str(runtime) + "min"
trakt json python
Posted by Anonymous on Tue 2nd Oct 2012 19:26
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.