Support reading & writing to STDIN & STDOUT respectively

This commit is contained in:
Ritiek Malhotra
2020-04-22 16:02:27 +05:30
parent f24c026ae4
commit 7ddc5c6348
5 changed files with 75 additions and 24 deletions

View File

@@ -1,31 +1,31 @@
from spotdl.authorize.services import AuthorizeSpotify
from spotdl import command_line
import sys
def match_arguments(arguments):
if arguments.tracks:
# TODO: Also support reading from stdin for -t parameter
# Also supported writing to stdout for all parameters
if len(arguments.tracks) > 1:
# log.warning("download multiple tracks with optimized list instead")
pass
for track in arguments.tracks:
command_line.helpers.download_track(track, arguments)
if track == "-":
for line in sys.stdin:
command_line.helpers.download_track(line, arguments)
else:
command_line.helpers.download_track(track, arguments)
elif arguments.list:
if arguments.write_m3u:
youtube_tools.generate_m3u(
track_file=arguments.list
)
else:
command_line.helpers.download_tracks_from_file(
list_download = {
"sequential": command_line.helpers.download_tracks_from_file,
"threaded" : command_line.helpers.download_tracks_from_file_threaded,
}[arguments.processor]
list_download(
arguments.list,
arguments,
)
# list_dl = downloader.ListDownloader(
# tracks_file=arguments.list,
# skip_file=arguments.skip,
# write_successful_file=arguments.write_successful,
# )
# list_dl.download_list()
elif arguments.playlist:
spotify_tools.write_playlist(
playlist_url=arguments.playlist, text_file=arguments.write_to