- import json
- import urllib2
- import base64
- #config
- base64string = base64.encodestring('user:pass')
- apikey= 'api'
- username ='user'
- 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)):
- for b in range(len(out[i]['episodes'])):
- showname = out[i]['episodes'][b]['show']['title'] #Fringe
- ep_name = out[i]['episodes'][b]['episode']['title'] #In Absentia
- network = out[i]['episodes'][b]['show']['network'] #FOX
- airtime = out[i]['episodes'][b]['show']['air_time'] #9:00pm
- season = out[i]['episodes'][b]['episode']['season'] #5
- ep_num = out[i]['episodes'][b]['episode']['number'] #2
- in_watch = out[i]['episodes'][b]['show']['in_watchlist'] #True
- airday = out[i]['episodes'][b]['show']['air_day'] #Friday
- runtime = out[i]['episodes'][b]['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 Wed 3rd Oct 2012 13:21
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.