Better destination handling

Aparently transmissionrpc also doesnt like
having `download_dir = None`. It should actually work now.
This commit is contained in:
Derek Schmidt 2018-06-12 10:25:25 -07:00
parent 4c81b4faae
commit 6d46811732
Signed by: skeh
GPG key ID: 0F5D491793B4035A

View file

@ -176,6 +176,7 @@ def main(config_path='config.json', seen_path='seen.txt', dry_run=False, no_seen
http_handler=config['rpc'].get('http_handler'),
timeout=config['rpc'].get('timeout')
)
default_download_dir = rpc.get_session().download_dir
# Choose the best item
for show, torrents in filtered.items():
item_config = show.getConfig(config)
@ -195,8 +196,11 @@ def main(config_path='config.json', seen_path='seen.txt', dry_run=False, no_seen
if rpc and not dry_run:
destination = item_config.get('destination')
if destination:
if not destination.startswith('/'):
destination = os.path.join(default_download_dir, destination)
destination = destination.format(show=show, torrent=torrent)
t = rpc.add_torrent(best_entry.link, download_dir=destination)
destination = os.path.expanduser(destination)
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))