diff --git a/README.md b/README.md index 825ae40..dfe3201 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Python packages: ``` Basic command line usage: - python zspotify Downloads the track, album, playlist or podcast episode specified as a command line argument. If an artist url is given, all albums by specified artist will be downloaded. + python zspotify Downloads the track, album, playlist or podcast episode specified as a command line argument. If an artist url is given, all albums by specified artist will be downloaded. Can take multiple urls. Extra command line options: -p, --playlist Downloads a saved playlist from your account diff --git a/zspotify/__main__.py b/zspotify/__main__.py index 875b767..2064e15 100644 --- a/zspotify/__main__.py +++ b/zspotify/__main__.py @@ -11,11 +11,12 @@ if __name__ == '__main__': action='store_true', help='Suppress the splash screen when loading.') group = parser.add_mutually_exclusive_group(required=True) - group.add_argument('url', + group.add_argument('urls', type=str, + # action='extend', default='', - nargs='?', - help='Downloads the track, album, playlist, podcast episode, or all albums by an artist from a url.') + nargs='*', + help='Downloads the track, album, playlist, podcast episode, or all albums by an artist from a url. Can take multiple urls.') group.add_argument('-ls', '--liked-songs', dest='liked_songs', action='store_true', @@ -32,3 +33,5 @@ if __name__ == '__main__': args = parser.parse_args() args.func(args) + + # print(args) diff --git a/zspotify/app.py b/zspotify/app.py index ad184df..b0cbb96 100644 --- a/zspotify/app.py +++ b/zspotify/app.py @@ -29,28 +29,29 @@ def client(args) -> None: print('[ DETECTED FREE ACCOUNT - USING HIGH QUALITY ]\n\n') ZSpotify.DOWNLOAD_QUALITY = AudioQuality.HIGH - if args.url: - track_id, album_id, playlist_id, episode_id, show_id, artist_id = regex_input_for_urls( - args.url) + if args.urls: + for spotify_url in args.urls: + track_id, album_id, playlist_id, episode_id, show_id, artist_id = regex_input_for_urls( + spotify_url) - if track_id is not None: - download_track(track_id) - elif artist_id is not None: - download_artist_albums(artist_id) - elif album_id is not None: - download_album(album_id) - elif playlist_id is not None: - playlist_songs = get_playlist_songs(playlist_id) - name, _ = get_playlist_info(playlist_id) - for song in playlist_songs: - download_track(song[TRACK][ID], - sanitize_data(name) + '/') - print('\n') - elif episode_id is not None: - download_episode(episode_id) - elif show_id is not None: - for episode in get_show_episodes(show_id): - download_episode(episode) + if track_id is not None: + download_track(track_id) + elif artist_id is not None: + download_artist_albums(artist_id) + elif album_id is not None: + download_album(album_id) + elif playlist_id is not None: + playlist_songs = get_playlist_songs(playlist_id) + name, _ = get_playlist_info(playlist_id) + for song in playlist_songs: + download_track(song[TRACK][ID], + sanitize_data(name) + '/') + print('\n') + elif episode_id is not None: + download_episode(episode_id) + elif show_id is not None: + for episode in get_show_episodes(show_id): + download_episode(episode) if args.playlist: download_from_user_playlist()