From 1896ea283e3817c6e1dadaaca38bfa2f43414d6e Mon Sep 17 00:00:00 2001 From: bobokun Date: Tue, 14 Dec 2021 10:18:10 -0500 Subject: [PATCH] Change default tag to format 2 --- config/config.yml.sample | 51 +++++++++++++++++++++++----------------- modules/config.py | 17 +++++++------- modules/qbittorrent.py | 12 +++++----- modules/util.py | 2 ++ 4 files changed, 45 insertions(+), 37 deletions(-) diff --git a/config/config.yml.sample b/config/config.yml.sample index 449cbf0..b94ae34 100644 --- a/config/config.yml.sample +++ b/config/config.yml.sample @@ -20,40 +20,30 @@ cat: movies: "/data/torrents/Movies" tv: "TV" -# Tag Parameters (Use either Format 1 or Format 2) +# Tag Parameters tags: - # Format 1 - # : - # Format 2 - # : + # : # This is the keyword in the tracker url + # Set tag name # tag: - # Will set the torrent Maximum share ratio until torrent is stopped from seeding/uploading. -2 means the global limit should be used, -1 means no limit. + # Will set the torrent Maximum share ratio until torrent is stopped from seeding/uploading. -2 means the global limit should be used, -1 means no limit. # max_ratio: 5.0 # Will set the torrent Maximum seeding time (min) until torrent is stopped from seeding. -2 means the global limit should be used, -1 means no limit. # max_seeding_time: 129600 # Will limit the upload speed KiB/s (KiloBytes/second) (-1 sets the limit to infinity) # limit_upload_speed: 150 - - #Format 1 Examples - animebytes.tv: AnimeBytes - beyond-hd: Beyond-HD - blutopia: Blutopia - cartoonchaos: CartoonChaos - landof.tv: BroadcasTheNet - myanonamouse: MaM - passthepopcorn: PassThePopcorn - privatehd: PrivateHD - tleechreload: TorrentLeech - torrentdb: TorrentDB - torrentleech: TorrentLeech - tv-vault: TV-Vault - - #Format 2 Examples + animebytes.tv: + tag: AnimeBytes avistaz: tag: Avistaz max_ratio: 5.0 max_seeding_time: 129600 limit_upload_speed: 150 + beyond-hd: + tag: Beyond-HD + blutopia: + tag: Blutopia + cartoonchaos: + tag: CartoonChaos digitalcore tag: DigitalCore max_ratio: 5.0 @@ -63,6 +53,23 @@ tags: hdts: tag: HDTorrents max_seeding_time: 129600 + landof.tv: + tag: BroadcasTheNet + myanonamouse: + tag: MaM + passthepopcorn: + tag: PassThePopcorn + privatehd: + tag: PrivateHD + tleechreload: + tag: TorrentLeech + torrentdb: + tag: TorrentDB + torrentleech: + tag: TorrentLeech + tv-vault: + tag: TV-Vault + #Tag Movies/Series that are not hard linked nohardlinks: diff --git a/modules/config.py b/modules/config.py index 1bc98a0..92783d9 100644 --- a/modules/config.py +++ b/modules/config.py @@ -123,24 +123,23 @@ class Config: except IndexError as e: logger.debug(f"Tracker Url:{url}") logger.debug(e) - # If using Format 1 + # If using Format 1 convert to format 2 if isinstance(tag_details,str): tags['new_tag'] = self.util.check_for_attribute(self.data, tag_url, parent="tags",default=default_tag) - if tags['new_tag'] == default_tag: self.data['tags'][tag_url] = default_tag + self.util.check_for_attribute(self.data, "tag", parent="tags",subparent=tag_url, default=tags['new_tag'],do_print=False) + if tags['new_tag'] == default_tag: self.data['tags'][tag_url]['tag'] = default_tag # Using Format 2 else: - if 'tag' not in tag_details: - logger.warning(f'No tags defined for {tag_url}. Please check your config.yml file. Setting tag to {tag_url}') tags['new_tag'] = self.util.check_for_attribute(self.data, "tag", parent="tags", subparent=tag_url, default=tag_url) if tags['new_tag'] == tag_url: self.data['tags'][tag_url]['tag'] = tag_url - tags['max_ratio'] = self.util.check_for_attribute(self.data, "max_ratio", parent="tags", subparent=tag_url, var_type="float", default_int=-2, default_is_none=True,do_print=False) - tags['max_seeding_time'] = self.util.check_for_attribute(self.data, "max_seeding_time", parent="tags", subparent=tag_url, var_type="int", default_int=-2, default_is_none=True,do_print=False) - tags['limit_upload_speed'] = self.util.check_for_attribute(self.data, "limit_upload_speed", parent="tags", subparent=tag_url, var_type="int", default_int=-1, default_is_none=True,do_print=False) + tags['max_ratio'] = self.util.check_for_attribute(self.data, "max_ratio", parent="tags", subparent=tag_url, var_type="float", default_int=-2, default_is_none=True,do_print=False,save=False) + tags['max_seeding_time'] = self.util.check_for_attribute(self.data, "max_seeding_time", parent="tags", subparent=tag_url, var_type="int", default_int=-2, default_is_none=True,do_print=False,save=False) + tags['limit_upload_speed'] = self.util.check_for_attribute(self.data, "limit_upload_speed", parent="tags", subparent=tag_url, var_type="int", default_int=-1, default_is_none=True,do_print=False,save=False) return (tags) if tags['url']: default_tag = tags['url'].split('/')[2].split(':')[0] - tags['new_tag'] = self.util.check_for_attribute(self.data, default_tag, parent="tags",default=default_tag) - self.data['tags'][str(default_tag)] = default_tag + tags['new_tag'] = self.util.check_for_attribute(self.data, "tag", parent="tags",subparent=default_tag, default=default_tag) + self.data['tags'][default_tag]['tag'] = default_tag logger.warning(f'No tags matched for {tags["url"]}. Please check your config.yml file. Setting tag to {default_tag}') return (tags) diff --git a/modules/qbittorrent.py b/modules/qbittorrent.py index 5f6877d..967f0f1 100644 --- a/modules/qbittorrent.py +++ b/modules/qbittorrent.py @@ -91,7 +91,7 @@ class Qbt: num_cat = 0 if self.config.args['cat_update']: separator(f"Updating Categories", space=False, border=False) - for torrent in alive_it(self.torrent_list): + for torrent in self.torrent_list: if torrent.category == '': new_cat = self.config.get_category(torrent.save_path) try: @@ -115,7 +115,7 @@ class Qbt: num_tags = 0 if self.config.args['tag_update']: separator(f"Updating Tags", space=False, border=False) - for torrent in alive_it(self.torrent_list): + for torrent in self.torrent_list: if torrent.tags == '' or ('cross-seed' in torrent.tags and len([e for e in torrent.tags.split(",") if not 'noHL' in e]) == 1): tags = self.config.get_tags([x.url for x in torrent.trackers if x.url.startswith('http')]) if tags["new_tag"]: @@ -261,7 +261,7 @@ class Qbt: 'TRUMP', 'RETITLED', ] - for torrent in alive_it(self.torrentissue): + for torrent in self.torrentissue: t_name = torrent.name t_count = self.torrentinfo[t_name]['count'] t_msg = self.torrentinfo[t_name]['msg'] @@ -320,7 +320,7 @@ class Qbt: dir_cs = self.config.cross_seed_dir dir_cs_out = os.path.join(dir_cs,'qbit_manage_added') os.makedirs(dir_cs_out,exist_ok=True) - for file in alive_it(cs_files): + for file in cs_files: t_name = file.split(']', 2)[2].split('.torrent')[0] # Substring Key match in dictionary (used because t_name might not match exactly with torrentdict key) # Returned the dictionary of filtered item @@ -350,7 +350,7 @@ class Qbt: if dry_run: print_line(f'{t_name} not found in torrents.',loglevel) else: print_line(f'{t_name} not found in torrents.','WARNING') #Tag missing cross-seed torrents tags - for torrent in alive_it(self.torrent_list): + for torrent in self.torrent_list: t_name = torrent.name if 'cross-seed' not in torrent.tags and self.torrentinfo[t_name]['count'] > 1 and self.torrentinfo[t_name]['first_hash'] != torrent.hash: tagged += 1 @@ -375,7 +375,7 @@ class Qbt: #sort by size and paused torrent_list = self.get_torrents({'status_filter':'paused','sort':'size'}) if torrent_list: - for torrent in alive_it(torrent_list): + for torrent in torrent_list: new_tag = self.config.get_tags([x.url for x in torrent.trackers if x.url.startswith('http')]) #Resume torrent if completed if torrent.progress == 1: diff --git a/modules/util.py b/modules/util.py index 27d1b64..ebf6f44 100644 --- a/modules/util.py +++ b/modules/util.py @@ -53,6 +53,8 @@ class check: if subparent not in loaded_config[parent] or not loaded_config[parent][subparent]: loaded_config[parent][subparent] = {attribute: default} elif attribute not in loaded_config[parent]: + if isinstance(loaded_config[parent][subparent],str): + loaded_config[parent][subparent] = {attribute: default} loaded_config[parent][subparent][attribute] = default else: endline = ""