ability to exclude tags when taggin noHL

This commit is contained in:
Jon 2021-09-28 22:26:42 -04:00
parent 6364577388
commit c748b30934
No known key found for this signature in database
GPG key ID: 9665BA6CF5DC2671
2 changed files with 60 additions and 40 deletions

View file

@ -41,6 +41,10 @@ nohardlinks:
# Mandatory to fill out directory parameter above to use this function (root_dir/remote_dir) # Mandatory to fill out directory parameter above to use this function (root_dir/remote_dir)
# This variable should be set to your category name of your completed movies/completed series in qbit. Acceptable variable can be any category you would like to tag if there are no hardlinks found # This variable should be set to your category name of your completed movies/completed series in qbit. Acceptable variable can be any category you would like to tag if there are no hardlinks found
movies-completed: movies-completed:
#<OPTIONAL> exclude_tags var: Will exclude the following tags when searching through the category.
exclude_tags:
- Beyond-HD
- AnimeBytes
#<OPTIONAL> cleanup var: WARNING!! Setting this as true Will remove and delete contents of any torrents that are in paused state and has the NoHL tag #<OPTIONAL> cleanup var: WARNING!! Setting this as true Will remove and delete contents of any torrents that are in paused state and has the NoHL tag
cleanup: false cleanup: false
#<OPTIONAL> max_ratio var: Will set the torrent Maximum share ratio until torrent is stopped from seeding/uploading #<OPTIONAL> max_ratio var: Will set the torrent Maximum share ratio until torrent is stopped from seeding/uploading
@ -50,6 +54,10 @@ nohardlinks:
#Can have additional categories set with separate ratio/seeding times defined. #Can have additional categories set with separate ratio/seeding times defined.
series-completed: series-completed:
#<OPTIONAL> exclude_tags var: Will exclude the following tags when searching through the category.
exclude_tags:
- Beyond-HD
- BroadcasTheNet
#<OPTIONAL> cleanup var: WARNING!! Setting this as true Will remove and delete contents of any torrents that are in paused state and has the NoHL tag #<OPTIONAL> cleanup var: WARNING!! Setting this as true Will remove and delete contents of any torrents that are in paused state and has the NoHL tag
cleanup: false cleanup: false
#<OPTIONAL> max_ratio var: Will set the torrent Maximum share ratio until torrent is stopped from seeding/uploading #<OPTIONAL> max_ratio var: Will set the torrent Maximum share ratio until torrent is stopped from seeding/uploading

View file

@ -491,16 +491,28 @@ def tag_nohardlinks():
t_del_cs = 0 #counter for the number of torrents that has no hard links and meets the criteria for ratio limit/seed limit for deletion including cross-seeds t_del_cs = 0 #counter for the number of torrents that has no hard links and meets the criteria for ratio limit/seed limit for deletion including cross-seeds
n_info = '' n_info = ''
tdel_dict = {} #dictionary to track the torrent names and content path that meet the deletion criteria tdel_dict = {} #dictionary to track the torrent names and content path that meet the deletion criteria
t_excl_tags = []#list of tags to exclude based on config.yml
torrent_list = client.torrents.info(category=category,filter='completed') torrent_list = client.torrents.info(category=category,filter='completed')
#Convert string to list if only one tag defined.
if ('exclude_tags' in nohardlinks[category]):
if isinstance(nohardlinks[category]['exclude_tags'],str):
t_excl_tags.append(nohardlinks[category]['exclude_tags'])
else:
t_excl_tags = nohardlinks[category]['exclude_tags']
if len(torrent_list) == 0: if len(torrent_list) == 0:
logger.error('The category ('+category+') defined in config.yml inside the nohardlinks section does not match any category in qbittorrent. Please make sure the category defined in config matches with one in qbittorrent.') logger.error('No torrents found in the category ('+category+') defined in config.yml inside the nohardlinks section. Please check if this matches with any category in qbittorrent and has 1 or more torrents.')
continue continue
for torrent in torrent_list: for torrent in torrent_list:
if args.dry_run != 'dry_run': if args.dry_run != 'dry_run':
torrent.resume() torrent.resume()
if('exclude_tags' in nohardlinks[category] and (any(tag in torrent.tags for tag in t_excl_tags))):
#Skip to the next torrent if we find any torrents that are in the exclude tag
continue
else:
#Checks for any hard links and not already tagged #Checks for any hard links and not already tagged
if (nohardlink(torrent['content_path'].replace(root_path,remote_path))): if (nohardlink(torrent['content_path'].replace(root_path,remote_path))):
#Will only tag new torrents that don't have noHL tag #Will only tag new torrents that don't have noHL tag
if('noHL' not in torrent.tags): if('noHL' not in torrent.tags):
t_count += 1 t_count += 1