Skip to content

Commit

Permalink
Fix for searcher not returning results
Browse files Browse the repository at this point in the history
  • Loading branch information
rembo10 committed May 26, 2024
1 parent 3e354ff commit ebba115
Showing 1 changed file with 23 additions and 29 deletions.
52 changes: 23 additions & 29 deletions headphones/searcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,27 @@
import headphones
from headphones.common import USER_AGENT
from headphones.helpers import (
bytes_to_mb,
has_token,
piratesize,
bytes_to_mb,
has_token,
piratesize,
replace_all,
replace_illegal_chars,
sab_replace_dots,
sab_replace_spaces,
replace_illegal_chars,
sab_replace_dots,
sab_replace_spaces,
sab_sanitize_foldername,
split_string
)
from headphones.types import Result
from headphones import logger, db, classes, sab, nzbget, request
from headphones import (
bandcamp,
deluge,
notifiers,
qbittorrent,
rutracker,
deluge,
notifiers,
qbittorrent,
rutracker,
soulseek,
transmission,
utorrent,
transmission,
utorrent
)

# Magnet to torrent services, for Black hole. Stolen from CouchPotato.
Expand Down Expand Up @@ -329,26 +329,21 @@ def do_sorted_search(album, new, losslessOnly, choose_specific_download=False):

else:

nzb_results = None
torrent_results = None
bandcamp_results = None
nzb_results = []
torrent_results = []
bandcamp_results = []

if NZB_PROVIDERS and NZB_DOWNLOADERS:
nzb_results = searchNZB(album, new, losslessOnly, albumlength, choose_specific_download)
nzb_results = searchNZB(album, new, losslessOnly,
albumlength, choose_specific_download)

if TORRENT_PROVIDERS:
torrent_results = searchTorrent(album, new, losslessOnly, albumlength,
choose_specific_download)
torrent_results = searchTorrent(album, new, losslessOnly,
albumlength, choose_specific_download)

if headphones.CONFIG.BANDCAMP:
bandcamp_results = searchBandcamp(album, new, albumlength)

if not nzb_results:
nzb_results = []

if not torrent_results:
torrent_results = []

results = nzb_results + torrent_results + bandcamp_results

if choose_specific_download:
Expand All @@ -370,7 +365,6 @@ def do_sorted_search(album, new, losslessOnly, choose_specific_download=False):
(data, result) = preprocess(sorted_search_results)

if data and result:
#print(f'going to send stuff to downloader. data: {data}, album: {album}')
send_to_downloader(data, result, album)


Expand Down Expand Up @@ -876,15 +870,15 @@ def send_to_downloader(data, result, album):
except Exception as e:
logger.error('Couldn\'t write NZB file: %s', e)
return

elif kind == 'bandcamp':
folder_name = bandcamp.download(album, result)
logger.info("Setting folder_name to: {}".format(folder_name))


elif kind == 'soulseek':
soulseek.download(user=result.user, filelist=result.files)
folder_name = result.folder
folder_name = result.folder

else:
folder_name = '%s - %s [%s]' % (
unidecode(album['ArtistName']).replace('/', '_'),
Expand Down Expand Up @@ -1983,7 +1977,7 @@ def preprocess(resultlist):

if result.kind == 'soulseek':
return True, result

if result.kind == 'torrent':

# rutracker always needs the torrent data
Expand Down

0 comments on commit ebba115

Please sign in to comment.