bug fix: Update tags with multiple tracker urls

This commit is contained in:
Jon 2021-03-09 20:57:56 -05:00
parent 3d302c8715
commit 6f2f9c481a
No known key found for this signature in database
GPG key ID: 9665BA6CF5DC2671

View file

@ -125,19 +125,18 @@ def get_category(path):
if f in path: if f in path:
category = i category = i
return category return category
else:
category = '' category = ''
logger.warning('No categories matched. Check your config.yml file. - Setting tag to NULL') logger.warning('No categories matched. Check your config.yml file. - Setting category to NULL')
return category return category
def get_tags(url): def get_tags(urls):
tag_path = cfg['tags'] tag_path = cfg['tags']
for i, f in tag_path.items(): for i, f in tag_path.items():
for url in urls:
if i in url: if i in url:
tag = f tag = f
return tag if tag: return tag,trunc_val(url, '/')
else:
tag = '' tag = ''
logger.warning('No tags matched. Check your config.yml file. Setting tag to NULL') logger.warning('No tags matched. Check your config.yml file. Setting tag to NULL')
return tag return tag
@ -173,7 +172,7 @@ def recheck():
torrent_sorted_list = client.torrents.info(status_filter='paused',sort='size') torrent_sorted_list = client.torrents.info(status_filter='paused',sort='size')
torrentdict = get_torrent_info(client.torrents.info(sort='added_on',reverse=True)) torrentdict = get_torrent_info(client.torrents.info(sort='added_on',reverse=True))
for torrent in torrent_sorted_list: for torrent in torrent_sorted_list:
new_tag = [get_tags(x.url) for x in torrent.trackers if x.url.startswith('http')] new_tag,t_url = get_tags([x.url for x in torrent.trackers if x.url.startswith('http')])
if torrent.tags == '': torrent.add_tags(tags=new_tag) if torrent.tags == '': torrent.add_tags(tags=new_tag)
#Resume torrent if completed #Resume torrent if completed
if torrent.progress == 1: if torrent.progress == 1:
@ -296,10 +295,7 @@ def update_tags():
torrent_list = client.torrents.info(sort='added_on',reverse=True) torrent_list = client.torrents.info(sort='added_on',reverse=True)
for torrent in torrent_list: for torrent in torrent_list:
if torrent.tags == '': if torrent.tags == '':
for x in torrent.trackers: new_tag,t_url = get_tags([x.url for x in torrent.trackers if x.url.startswith('http')])
if x.url.startswith('http'):
t_url = trunc_val(x.url, '/')
new_tag = get_tags(x.url)
if args.dry_run == 'dry_run': if args.dry_run == 'dry_run':
logger.dryrun(f'\n - Torrent Name: {torrent.name}' logger.dryrun(f'\n - Torrent Name: {torrent.name}'
f'\n - New Tag: {new_tag}' f'\n - New Tag: {new_tag}'