Soulseek tweaks # 2

push results through filters
This commit is contained in:
AdeHub
2024-06-19 20:33:40 +12:00
parent acf73368c9
commit dae4d80490
2 changed files with 20 additions and 7 deletions

View File

@@ -373,8 +373,10 @@ def do_sorted_search(album, new, losslessOnly, choose_specific_download=False):
if BANDCAMP:
bandcamp_results = searchBandcamp(album, new, albumlength)
if SOULSEEK:
soulseek_results = searchSoulseek(album, new, losslessOnly, albumlength)
# TODO: get this working
# if SOULSEEK:
# soulseek_results = searchSoulseek(album, new, losslessOnly,
# albumlength, choose_specific_download)
results = nzb_results + torrent_results + bandcamp_results + soulseek_results
@@ -1451,7 +1453,6 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None,
title = item.title.get_text()
url = item.find("link").next_sibling.strip()
seeders = int(item.find("torznab:attr", attrs={"name": "seeders"}).get('value'))
# Torrentech hack - size currently not returned, make it up
if 'torrentech' in torznab_host[0]:
if albumlength:
@@ -1973,7 +1974,8 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None,
return results
def searchSoulseek(album, new=False, losslessOnly=False, albumlength=None):
def searchSoulseek(album, new=False, losslessOnly=False, albumlength=None,
choose_specific_download=False):
# Not using some of the input stuff for now or ever
replacements = {
'...': '',
@@ -2011,13 +2013,24 @@ def searchSoulseek(album, new=False, losslessOnly=False, albumlength=None):
term = ''
try:
results = soulseek.search(artist=cleanartist, album=cleanalbum, year=year, losslessOnly=losslessOnly,
resultlist = soulseek.search(artist=cleanartist, album=cleanalbum, year=year, losslessOnly=losslessOnly,
allow_lossless=allow_lossless, num_tracks=num_tracks, user_search_term=term)
if not results:
if not resultlist:
logger.info("No valid results found from Soulseek")
# filter results
results = [result for result in resultlist if verifyresult(result.title, cleanartist, term, losslessOnly)]
# Additional filtering for size etc
if results and not choose_specific_download:
results = more_filtering(results, album, albumlength, new)
return results
except Exception as e:
logger.error(f"Soulseek error, check server logs: {e}")
return None
def get_album_track_count(album_id):

View File

@@ -120,7 +120,7 @@ def process_results(results, losslessOnly, allow_lossless, num_tracks, ignore_tr
queueLength=album_data['queueLength'],
files=album_data['files'],
kind='soulseek',
url='http://thisisnot.needed', # URL is needed in other parts of the program.
url='http://' + album_data['user'] + album_title, # URL is needed in other parts of the program.
#folder=os.path.basename(directory)
folder = album_title
))