Compare commits
No commits in common. "782055e4ef9901624d2d5305480cccbf6079bc43" and "81fb8972e14c2eb5782b6aee50e30c90e1c42338" have entirely different histories.
782055e4ef
...
81fb8972e1
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import feedparser
|
||||
import subprocess
|
||||
import click
|
||||
import re
|
||||
import json
|
||||
|
@ -8,14 +9,11 @@ import hashlib
|
|||
import sys
|
||||
import os
|
||||
import transmissionrpc
|
||||
import requests
|
||||
import base64
|
||||
|
||||
from operator import itemgetter
|
||||
|
||||
def printe(*args, **kwargs):
|
||||
print(*args, file=sys.stderr, **kwargs)
|
||||
|
||||
|
||||
class Resolution:
|
||||
# In decending order of quality, since indexes are used to tell whats "better"
|
||||
names = [
|
||||
|
@ -30,7 +28,6 @@ class Resolution:
|
|||
('240p', 'QVGA'),
|
||||
('Unknown', 'None', None)
|
||||
]
|
||||
|
||||
def __init__(self, _name):
|
||||
self.name = _name
|
||||
for family in self.names:
|
||||
|
@ -48,21 +45,16 @@ class Resolution:
|
|||
if not isinstance(other, Resolution):
|
||||
raise TypeError
|
||||
return self.names.index(self.family) > other.names.index(other.family)
|
||||
|
||||
def __eq__(self, other):
|
||||
if not isinstance(other, Resolution):
|
||||
raise TypeError
|
||||
return self.names.index(self.family) == other.names.index(other.family)
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
||||
def __gt__(self, other):
|
||||
return not self.__lt__(other)
|
||||
|
||||
def __le__(self, other):
|
||||
return self.__lt__(other) or self.__eq__(other)
|
||||
|
||||
def __ge__(self, other):
|
||||
return self.__gt__(other) or self.__eq__(other)
|
||||
|
||||
|
@ -92,7 +84,6 @@ class Show:
|
|||
def __eq__(self, other):
|
||||
return self.key == other.key
|
||||
|
||||
|
||||
class Torrent:
|
||||
def __init__(self, name, link, id=None, episode=None, quality=None, encoding=None):
|
||||
self.name = name
|
||||
|
@ -118,6 +109,7 @@ class Torrent:
|
|||
return self.id == other.id
|
||||
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option('--config', 'config_path', type=click.Path(readable=True, dir_okay=False), default='config.json', help="Config file in JSON format.", )
|
||||
@click.option('--seen-file', 'seen_path', type=click.Path(writable=True, dir_okay=False), default='seen.txt', help="File to store seen torrents in. Pruning is acceptable if pruned torrent id's will not appear in the RSS feeds.")
|
||||
|
@ -186,8 +178,6 @@ def main(config_path='config.json', seen_path='seen.txt', dry_run=False, no_seen
|
|||
timeout=config['rpc'].get('timeout')
|
||||
)
|
||||
default_download_dir = rpc.get_session().download_dir
|
||||
else:
|
||||
rpc = None
|
||||
# Choose the best item
|
||||
for show, torrents in filtered.items():
|
||||
item_config = show.getConfig(config)
|
||||
|
@ -213,13 +203,7 @@ def main(config_path='config.json', seen_path='seen.txt', dry_run=False, no_seen
|
|||
destination = os.path.join(default_download_dir, destination)
|
||||
if not os.path.exists(destination):
|
||||
os.makedirs(destination)
|
||||
|
||||
if best_entry.link.startswith('http'):
|
||||
r = requests.get(best_entry.link)
|
||||
r.raise_for_status()
|
||||
rpc.add_torrent(base64.b64encode(r.content).decode('utf-8'), download_dir=destination or default_download_dir)
|
||||
else:
|
||||
rpc.add_torrent(best_entry.link, download_dir=destination or default_download_dir)
|
||||
t = rpc.add_torrent(best_entry.link, download_dir=destination or default_download_dir)
|
||||
else:
|
||||
printe("No torrents for {show} pass quality restrictions".format(show=show.name))
|
||||
|
||||
|
@ -228,7 +212,6 @@ def main(config_path='config.json', seen_path='seen.txt', dry_run=False, no_seen
|
|||
with open(seen_path, 'w') as seen_file:
|
||||
seen_file.write('\n'.join(seen))
|
||||
|
||||
|
||||
# Usual python stuff
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Loading…
Reference in New Issue