From 56791824ac01232afdcb0c835a7ecf0897a60919 Mon Sep 17 00:00:00 2001 From: Jon Date: Sat, 27 Feb 2021 06:05:17 -0500 Subject: [PATCH] Cross-seed implemented watch_path. --- config.yml | 12 +++++++++--- qbit_manage.py | 24 ++++++++++++++---------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/config.yml b/config.yml index dca09d8..fb50a5c 100644 --- a/config.yml +++ b/config.yml @@ -13,9 +13,15 @@ directory: cross_seed: '/your/path/here/' # Category/Pathing Parameters cat: - # : - movies: movies - tv: tv + # + # - save_path #Path of your save directory. Can be a keyword or full path + # - watch_path #OPTIONAL parameter: where cross_seed will drop the torrents to. (Defaults to save_path if not defined) + movies: + - save_path: '/data/torrents/Movies' + - watch_path: '/data/torrents/watch/Movies' + tv: + - save_path: 'TV' + # Tag Parameters tags: # : diff --git a/qbit_manage.py b/qbit_manage.py index d1633d4..c87bdfe 100644 --- a/qbit_manage.py +++ b/qbit_manage.py @@ -116,11 +116,11 @@ def trunc_val(s, d, n=3): def get_category(path): - cat_path = cfg["cat"] - for i, f in cat_path.items(): - if i in path: - category = f - return category + for cat, attr in cfg["cat"].items(): + for attr_path in attr: + if 'save_path' in attr_path and attr_path['save_path'] in path: + category = cat + return category else: category = '' logger.warning('No categories matched. Check your config.yml file. - Setting tag to NULL') @@ -182,13 +182,17 @@ def cross_seed(): torrentdict = get_torrent_info(torrent_list) for file in cs_files: t_name = file.split("]",2)[2].split('.torrent')[0] + dest = '' if t_name in torrentdict: category = torrentdict[t_name]['Category'] - dest = torrentdict[t_name]['save_path'] - - #Replace remote directory with local directory - for dir in cfg["remote_dir"]: - if dir in dest : dest = dest.replace(dir,cfg["remote_dir"][dir]) + dest = os.path.join(torrentdict[t_name]['save_path'],'') #Default save destination to save path if watch_path not defined + for attr_path in cfg["cat"][category]: + if 'watch_path' in attr_path: #Update to watch path if defined + dest=os.path.join(attr_path['watch_path'],'') + if "remote_dir" in cfg: + #Replace remote directory with local directory + for dir in cfg["remote_dir"]: + if dir in dest : dest = dest.replace(dir,cfg["remote_dir"][dir]) src = dir_cs + file dest += file categories.append(category)