def match_args(): if const.args.song: for track in const.args.song: track_dl = downloader.Downloader(raw_song=track) track_dl.download_single() elif const.args.list: if const.args.write_m3u: youtube_tools.generate_m3u(track_file=const.args.list) else: list_dl = downloader.ListDownloader( tracks_file=const.args.list, skip_file=const.args.skip, write_successful_file=const.args.write_successful, ) list_dl.download_list() elif const.args.clear_playlist: spotify_tools.clear_playlist(const.args.clear_playlist) elif const.args.playlist: spotify_tools.write_playlist(playlist_url=const.args.playlist, text_file=const.args.write_to) elif const.args.album: spotify_tools.write_album(album_url=const.args.album, text_file=const.args.write_to) elif const.args.all_albums: spotify_tools.write_all_albums_from_artist( artist_url=const.args.all_albums, text_file=const.args.write_to) elif const.args.username: spotify_tools.write_user_playlist(username=const.args.username, text_file=const.args.write_to)
def test_dry_download_list(tmpdir): const.args.folder = str(tmpdir) const.args.dry_run = True file_path = os.path.join(const.args.folder, "test_list.txt") with open(file_path, "w") as f: f.write(TRACK_URL) list_dl = downloader.ListDownloader(file_path) downloaded_song, *_ = list_dl.download_list() assert downloaded_song == TRACK_URL
def download_list(list_file, skip_file=None, write_successful_file=None): """ Download list of songs :param list_file: file list contains all the songs to download :param skip_file: file contains songs to skip when downloading :param write_successful_file: file to write successful downloads of songs """ list_downloader = spotdl_downloader.ListDownloader( tracks_file=list_file, skip_file=skip_file, write_successful_file=write_successful_file) list_downloader.download_list()