38
38
import headphones
39
39
from headphones .common import USER_AGENT
40
40
from headphones .helpers import (
41
- bytes_to_mb ,
42
- has_token ,
43
- piratesize ,
41
+ bytes_to_mb ,
42
+ has_token ,
43
+ piratesize ,
44
44
replace_all ,
45
- replace_illegal_chars ,
46
- sab_replace_dots ,
47
- sab_replace_spaces ,
45
+ replace_illegal_chars ,
46
+ sab_replace_dots ,
47
+ sab_replace_spaces ,
48
48
sab_sanitize_foldername ,
49
49
split_string
50
50
)
51
51
from headphones .types import Result
52
52
from headphones import logger , db , classes , sab , nzbget , request
53
53
from headphones import (
54
54
bandcamp ,
55
- deluge ,
56
- notifiers ,
57
- qbittorrent ,
58
- rutracker ,
55
+ deluge ,
56
+ notifiers ,
57
+ qbittorrent ,
58
+ rutracker ,
59
59
soulseek ,
60
- transmission ,
61
- utorrent ,
60
+ transmission ,
61
+ utorrent
62
62
)
63
63
64
64
# Magnet to torrent services, for Black hole. Stolen from CouchPotato.
@@ -329,26 +329,21 @@ def do_sorted_search(album, new, losslessOnly, choose_specific_download=False):
329
329
330
330
else :
331
331
332
- nzb_results = None
333
- torrent_results = None
334
- bandcamp_results = None
332
+ nzb_results = []
333
+ torrent_results = []
334
+ bandcamp_results = []
335
335
336
336
if NZB_PROVIDERS and NZB_DOWNLOADERS :
337
- nzb_results = searchNZB (album , new , losslessOnly , albumlength , choose_specific_download )
337
+ nzb_results = searchNZB (album , new , losslessOnly ,
338
+ albumlength , choose_specific_download )
338
339
339
340
if TORRENT_PROVIDERS :
340
- torrent_results = searchTorrent (album , new , losslessOnly , albumlength ,
341
- choose_specific_download )
341
+ torrent_results = searchTorrent (album , new , losslessOnly ,
342
+ albumlength , choose_specific_download )
342
343
343
344
if headphones .CONFIG .BANDCAMP :
344
345
bandcamp_results = searchBandcamp (album , new , albumlength )
345
346
346
- if not nzb_results :
347
- nzb_results = []
348
-
349
- if not torrent_results :
350
- torrent_results = []
351
-
352
347
results = nzb_results + torrent_results + bandcamp_results
353
348
354
349
if choose_specific_download :
@@ -370,7 +365,6 @@ def do_sorted_search(album, new, losslessOnly, choose_specific_download=False):
370
365
(data , result ) = preprocess (sorted_search_results )
371
366
372
367
if data and result :
373
- #print(f'going to send stuff to downloader. data: {data}, album: {album}')
374
368
send_to_downloader (data , result , album )
375
369
376
370
@@ -876,15 +870,15 @@ def send_to_downloader(data, result, album):
876
870
except Exception as e :
877
871
logger .error ('Couldn\' t write NZB file: %s' , e )
878
872
return
873
+
879
874
elif kind == 'bandcamp' :
880
875
folder_name = bandcamp .download (album , result )
881
876
logger .info ("Setting folder_name to: {}" .format (folder_name ))
882
877
883
-
884
878
elif kind == 'soulseek' :
885
879
soulseek .download (user = result .user , filelist = result .files )
886
- folder_name = result .folder
887
-
880
+ folder_name = result .folder
881
+
888
882
else :
889
883
folder_name = '%s - %s [%s]' % (
890
884
unidecode (album ['ArtistName' ]).replace ('/' , '_' ),
@@ -1983,7 +1977,7 @@ def preprocess(resultlist):
1983
1977
1984
1978
if result .kind == 'soulseek' :
1985
1979
return True , result
1986
-
1980
+
1987
1981
if result .kind == 'torrent' :
1988
1982
1989
1983
# rutracker always needs the torrent data
0 commit comments