Bug fix: Handle public trackers only using DHT

This commit is contained in:
Jon 2021-11-27 15:10:29 -05:00
parent e4c2b948be
commit ac61eb093e
No known key found for this signature in database
GPG key ID: 9665BA6CF5DC2671

View file

@ -203,12 +203,12 @@ def get_category(path):
category = '' category = ''
return category return category
category = '' category = ''
logger.warning('No categories matched. Check your config.yml file. - Setting category to NULL') logger.warning(f'No categories matched for the save path {path}. Check your config.yml file. - Setting category to NULL')
return category return category
#Get tags from config file based on keyword #Get tags from config file based on keyword
def get_tags(urls): def get_tags(urls):
if 'tags' in cfg and cfg["tags"] != None: if 'tags' in cfg and cfg["tags"] != None and 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: for url in urls:
@ -219,7 +219,7 @@ def get_tags(urls):
tag = ('','') tag = ('','')
return tag return tag
tag = ('','') tag = ('','')
logger.warning('No tags matched. Check your config.yml file. Setting tag to NULL') logger.warning(f'No tags matched for {urls}. Check your config.yml file. Setting tag to NULL')
return tag return tag
@ -266,6 +266,8 @@ def get_torrent_info(t_list):
save_path = torrent.save_path save_path = torrent.save_path
category = get_category(save_path) category = get_category(save_path)
is_complete = False is_complete = False
msg = None
status = None
if torrent.name in torrentdict: if torrent.name in torrentdict:
t_count = torrentdict[torrent.name]['count'] + 1 t_count = torrentdict[torrent.name]['count'] + 1
msg_list = torrentdict[torrent.name]['msg'] msg_list = torrentdict[torrent.name]['msg']
@ -278,9 +280,12 @@ def get_torrent_info(t_list):
status_list = [] status_list = []
is_complete = torrent.state_enum.is_complete is_complete = torrent.state_enum.is_complete
first_hash = torrent.hash first_hash = torrent.hash
try:
msg,status = [(x.msg,x.status) for x in torrent.trackers if x.url.startswith('http')][0] msg,status = [(x.msg,x.status) for x in torrent.trackers if x.url.startswith('http')][0]
msg_list.append(msg) except IndexError:
status_list.append(status) pass
if msg != None: msg_list.append(msg)
if status != None: status_list.append(status)
torrentattr = {'Category': category, 'save_path': save_path, 'count': t_count, 'msg': msg_list, 'status': status_list, 'is_complete': is_complete, 'first_hash':first_hash} torrentattr = {'Category': category, 'save_path': save_path, 'count': t_count, 'msg': msg_list, 'status': status_list, 'is_complete': is_complete, 'first_hash':first_hash}
torrentdict[torrent.name] = torrentattr torrentdict[torrent.name] = torrentattr
return torrentdict return torrentdict
@ -406,10 +411,11 @@ def set_category():
num_cat = 0 num_cat = 0
for torrent in torrent_list: for torrent in torrent_list:
if torrent.category == '': if torrent.category == '':
for x in torrent.trackers:
if x.url.startswith('http'):
t_url = trunc_val(x.url, '/')
new_cat = get_category(torrent.save_path) new_cat = get_category(torrent.save_path)
try:
t_url = [trunc_val(x.url, '/') for x in torrent.trackers if x.url.startswith('http')][0]
except IndexError:
t_url = None
if dry_run: if dry_run:
logger.dryrun(util.insert_space(f'Torrent Name: {torrent.name}',3)) logger.dryrun(util.insert_space(f'Torrent Name: {torrent.name}',3))
logger.dryrun(util.insert_space(f'New Category: {new_cat}',3)) logger.dryrun(util.insert_space(f'New Category: {new_cat}',3))
@ -440,6 +446,7 @@ def set_tags():
for torrent in torrent_list: for torrent in 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): if torrent.tags == '' or ('cross-seed' in torrent.tags and len([e for e in torrent.tags.split(",") if not 'noHL' in e]) == 1):
new_tag,t_url = 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 new_tag:
if dry_run: if dry_run:
logger.dryrun(util.insert_space(f'Torrent Name: {torrent.name}',3)) logger.dryrun(util.insert_space(f'Torrent Name: {torrent.name}',3))
logger.dryrun(util.insert_space(f'New Tag: {new_tag}',8)) logger.dryrun(util.insert_space(f'New Tag: {new_tag}',8))