Advertisement
stubborn_d0nkey

Flexget+Trakt Series begin -- only for one list

Feb 17th, 2014
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.44 KB | None | 0 0
  1. #/usr/bin/python2.7
  2. import subprocess
  3. import json
  4. import hashlib
  5. import requests
  6. ###CONFIG###############################################
  7. username='USERNAME'
  8. password='PASSWORD'
  9. api='API'
  10. list_name='LIST NAME'
  11. ########################################################
  12. #The rest you don't have to worry about
  13. list_name=list_name.lower()
  14.  # These characters are just stripped in the url
  15. for char in '!@#$%^*()[]{}/=?+\\|-_':
  16.     list_name = list_name.replace(char, '')
  17. # These characters get replaced
  18. list_name = list_name.replace('&', 'and')
  19. list_name = list_name.replace(' ', '-')
  20. auth = {'username':username,
  21.         'password':password}
  22. url_base='http://api.trakt.tv/'
  23. url=url_base+'user/list.json/'+api+'/'+username+'/'+list_name
  24. result=requests.post(url, data=json.dumps(auth))
  25. data=result.json()
  26. listTitles=[]
  27. for item in data["items"]:
  28.     if 'show' in item:
  29.         listTitles.append(item['show']['title'])
  30. url=url_base+'user/library/shows/watched.json/'+api+'/'+username
  31. result=requests.post(url, data=json.dumps(auth))
  32. data=result.json()
  33. command_base='flexget series begin'
  34. for item in data:
  35.     title=item['title']
  36.     if title in listTitles:
  37.         season=item['seasons'][0]['season']
  38.         episode=item['seasons'][0]['episodes'][-1]
  39.         next_ep='S'+str(season).zfill(2)+'E'+str((episode+1)).zfill(2)
  40.         command=command_base+' \''+title+'\' '+next_ep
  41.         print command
  42.         subprocess.call(command,shell=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement