Last active
September 2, 2017 18:14
-
-
Save Hellowlol/85f2748889b23a5709066481bff27c2c to your computer and use it in GitHub Desktop.
Archive sdtv, sd dvd medusa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
apikey = '' | |
U = 'http://10.0.0.97:9009/' | |
AU = U + 'api/v1/' + apikey +'?cmd=%s' | |
session = requests.Session() | |
episodes_to_archive = [] | |
archive_qualitys = ['SD', 'SD DVD', 'SDTV'] | |
def gogo(): | |
print('Grabbing all your shows') | |
for show in session.get(AU % 'shows').json()['data']: | |
sub = 'show.seasons&indexerid=%s' % show | |
for season_nr, episodes in session.get(AU % sub).json()['data'].items(): | |
for episode_nr, episode in episodes.items(): | |
if episode.get('status') == 'Downloaded' and episode.get('quality', '') in archive_qualitys: | |
ssxx = '%sx%s' % (season_nr, episode_nr) | |
d = {'indexerid': show, | |
'ssxx': ssxx, | |
'location': episode.get('location')} | |
episodes_to_archive.append(d) | |
print('%s to archive' % len(episodes_to_archive)) | |
for archive_ep in episodes_to_archive: | |
achive_episode(archive_ep) | |
def achive_episode(d): | |
sub = 'home/setStatus?show=%s&eps=%s&status=106&direct=1' % (d['indexerid'], d['ssxx']) | |
r = session.get(U + sub) | |
if r.status_code == 200 and r.json().get('result') == 'success': | |
print(r.url) | |
print('Archived %s' % d['location']) | |
if __name__ == '__main__': | |
gogo() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment