Compare commits
No commits in common. "78bb0b00079f6337a86e8949997ef94ec60af09c" and "279f0cbbf0d9303e458a573d5b145c5fdf3ed6f5" have entirely different histories.
78bb0b0007
...
279f0cbbf0
|
@ -35,9 +35,6 @@ class Resolution:
|
||||||
else:
|
else:
|
||||||
raise ValueError("Did not recongnize resolution name. See Resolution.names")
|
raise ValueError("Did not recongnize resolution name. See Resolution.names")
|
||||||
|
|
||||||
def getNormalizedName(self):
|
|
||||||
return self.family[0]
|
|
||||||
|
|
||||||
# Rich comparison support
|
# Rich comparison support
|
||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
if not isinstance(other, Resolution):
|
if not isinstance(other, Resolution):
|
||||||
|
@ -111,8 +108,7 @@ class Torrent:
|
||||||
@click.command()
|
@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('--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.")
|
@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.")
|
||||||
@click.option('--no-dedup', 'no_seen', type=click.BOOL, is_flag=True, default=False, help="Don't save seen torrents to the seen file.")
|
def main(config_path='config.json', seen_path='seen.txt'):
|
||||||
def main(config_path='config.json', seen_path='seen.txt', no_seen=False):
|
|
||||||
# Get our config
|
# Get our config
|
||||||
with open(config_path, 'r') as config_file:
|
with open(config_path, 'r') as config_file:
|
||||||
config_json = ''.join(config_file.readlines())
|
config_json = ''.join(config_file.readlines())
|
||||||
|
@ -170,18 +166,17 @@ def main(config_path='config.json', seen_path='seen.txt', no_seen=False):
|
||||||
torrents = [torrent for torrent in torrents if torrent.quality >= Resolution(item_config['min-quality'])]
|
torrents = [torrent for torrent in torrents if torrent.quality >= Resolution(item_config['min-quality'])]
|
||||||
|
|
||||||
if len(torrents) > 0:
|
if len(torrents) > 0:
|
||||||
best_entry = sorted(torrents, key=lambda t: t.quality, reverse=True)[0]
|
best_entry = sorted(torrents, key=lambda t: t.quality)[0]
|
||||||
# Output the magnet / torrent link
|
# Output the magnet / torrent link
|
||||||
printe("Choosing {torrent} as best choice for {show} (quality: {res})".format(torrent=best_entry.id, show=show.name, res=best_entry.quality.getNormalizedName()))
|
printe("Choosing {torrent} as best choice for {show}".format(torrent=torrent.id, show=show.name))
|
||||||
# TODO: transmission-cli subprocess call here?
|
# TODO: transmission-cli subprocess call here?
|
||||||
print(best_entry.link)
|
print(best_entry.link)
|
||||||
else:
|
else:
|
||||||
printe("No torrents for {show} pass quality restrictions".format(show=show.name))
|
printe("No torrents for {show} pass quality restrictions".format(show=show.name))
|
||||||
|
|
||||||
# Save our records to a file for later use
|
# Save our records to a file for later use
|
||||||
if not no_seen:
|
with open(seen_path, 'w') as seen_file:
|
||||||
with open(seen_path, 'w') as seen_file:
|
seen_file.write('\n'.join(seen))
|
||||||
seen_file.write('\n'.join(seen))
|
|
||||||
|
|
||||||
# Usual python stuff
|
# Usual python stuff
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue