18
18
get_item_name ,
19
19
)
20
20
21
- from spotify_dl .youtube import download_songs , default_filename , playlist_num_filename , dump_json
21
+ from spotify_dl .youtube import (
22
+ download_songs ,
23
+ default_filename ,
24
+ playlist_num_filename ,
25
+ dump_json ,
26
+ )
22
27
23
28
24
29
def spotify_dl ():
@@ -54,7 +59,7 @@ def spotify_dl():
54
59
"--dump-json" ,
55
60
action = "store_true" ,
56
61
help = "Dump info-json using youtube-dl" ,
57
- default = False
62
+ default = False ,
58
63
)
59
64
parser .add_argument (
60
65
"-f" ,
@@ -95,8 +100,8 @@ def spotify_dl():
95
100
"-r" ,
96
101
"--remove-trailing-tracks" ,
97
102
default = "no" ,
98
- action = "store_true " ,
99
- help = "Whether we should delete tracks that were previously downloaded but are not longer in the playlist"
103
+ action = "store " ,
104
+ help = "Whether we should delete tracks that were previously downloaded but are not longer in the playlist" ,
100
105
)
101
106
parser .add_argument (
102
107
"-V" ,
@@ -143,7 +148,7 @@ def spotify_dl():
143
148
"Requested cores %d exceeds available %d, using %d cores." ,
144
149
args .multi_core ,
145
150
num_cores ,
146
- num_cores - 1
151
+ num_cores - 1 ,
147
152
)
148
153
args .multi_core = num_cores - 1
149
154
if args .version :
@@ -177,16 +182,13 @@ def spotify_dl():
177
182
)
178
183
)
179
184
log .debug ("Arguments: %s " , args )
180
- log .info (
181
- "Sponsorblock enabled?: %s" ,
182
- args .use_sponsorblock
183
- )
185
+ log .info ("Sponsorblock enabled?: %s" , args .use_sponsorblock )
184
186
valid_urls = validate_spotify_urls (args .url )
185
187
if not valid_urls :
186
188
sys .exit (1 )
187
189
188
190
url_data = {"urls" : []}
189
-
191
+ start_time = time . time ()
190
192
for url in valid_urls :
191
193
url_dict = {}
192
194
item_type , item_id = parse_spotify_url (url )
@@ -195,10 +197,7 @@ def spotify_dl():
195
197
PurePath .joinpath (Path (args .output ), Path (directory_name ))
196
198
)
197
199
url_dict ["save_path" ].mkdir (parents = True , exist_ok = True )
198
- log .info (
199
- "Saving songs to %s directory" ,
200
- directory_name
201
- )
200
+ log .info ("Saving songs to %s directory" , directory_name )
202
201
url_dict ["songs" ] = fetch_tracks (sp , item_type , url )
203
202
url_data ["urls" ].append (url_dict .copy ())
204
203
if args .dump_json is True :
@@ -215,18 +214,14 @@ def spotify_dl():
215
214
skip_mp3 = args .skip_mp3 ,
216
215
keep_playlist_order = args .keep_playlist_order ,
217
216
no_overwrites = args .no_overwrites ,
218
- remove_trailing_tracks = args .remove_trailing_tracks ,
217
+ remove_trailing_tracks = ( args .remove_trailing_tracks [ 0 ]. lower ()) ,
219
218
use_sponsorblock = args .use_sponsorblock ,
220
219
file_name_f = file_name_f ,
221
220
multi_core = args .multi_core ,
222
221
proxy = args .proxy ,
223
222
)
223
+ log .info ("Download completed in %.2f seconds." , time .time () - start_time )
224
224
225
225
226
226
if __name__ == "__main__" :
227
- start_time = time .time ()
228
227
spotify_dl ()
229
- log .info (
230
- "Download completed in %f seconds." ,
231
- time .time () - start_time
232
- )
0 commit comments