pastebin - collaborative debugging tool
kpaste.net RSS


trakt json python
Posted by Anonymous on Wed 3rd Oct 2012 13:21
raw | new post

  1. import json
  2. import urllib2
  3. import base64
  4. #config
  5. base64string = base64.encodestring('user:pass')
  6. apikey= 'api'
  7. username ='user'
  8. apipath='/user/calendar/shows.json/'
  9.  
  10.  
  11. #funcs
  12. def user_cal_shows():
  13.         request = urllib2.Request("https://api.trakt.tv/user/calendar/shows.json/" + apikey + "/" + username)
  14.         request.add_header("Authorization", "Basic %s" % base64string)
  15.         return json.load(urllib2.urlopen(request))
  16.  
  17.  
  18. out = user_cal_shows()
  19.  
  20. for i in range(len(out)):
  21.         for b in range(len(out[i]['episodes'])):
  22.                 showname = out[i]['episodes'][b]['show']['title']  #Fringe
  23.                 ep_name = out[i]['episodes'][b]['episode']['title']  #In Absentia
  24.                 network = out[i]['episodes'][b]['show']['network']  #FOX
  25.                 airtime = out[i]['episodes'][b]['show']['air_time']  #9:00pm
  26.                 season = out[i]['episodes'][b]['episode']['season']  #5
  27.                 ep_num = out[i]['episodes'][b]['episode']['number']  #2
  28.                 in_watch = out[i]['episodes'][b]['show']['in_watchlist'] #True
  29.                 airday = out[i]['episodes'][b]['show']['air_day']  #Friday
  30.                 runtime = out[i]['episodes'][b]['show']['runtime']  #60v
  31.  
  32.                 print showname + " airs at " +  airtime + " on " + airday
  33.                 print "\t " + str(season) + "." + str(ep_num) + " - " + ep_name + " " + network
  34.                 print "\t watchlist: " + str(in_watch) + " - runtime: " + str(runtime) + "min"

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.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at