Even BETTER destination handling

Create dir (recursively) if it doesnt exist
This commit is contained in:
Derek Schmidt 2018-06-12 10:33:02 -07:00
parent 6d46811732
commit 8843604cea
Signed by: skeh
GPG key ID: 0F5D491793B4035A

View file

@ -196,10 +196,12 @@ 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)
destination = os.path.expanduser(destination)
if not destination.startswith('/'):
destination = os.path.join(default_download_dir, destination)
if not os.path.exists(destination):
os.makedirs(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))