From 542201091d93dbe4915e2226b71faa35151ee1e1 Mon Sep 17 00:00:00 2001 From: Ritiek Malhotra Date: Mon, 4 Feb 2019 15:24:37 +0530 Subject: [PATCH 1/3] Fetch all artist albums by default --- spotdl/spotify_tools.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/spotdl/spotify_tools.py b/spotdl/spotify_tools.py index 2ba0396..c0e6b74 100644 --- a/spotdl/spotify_tools.py +++ b/spotdl/spotify_tools.py @@ -158,13 +158,13 @@ def fetch_album(album): return album -def fetch_albums_from_artist(artist_url, album_type="album"): +def fetch_albums_from_artist(artist_url, album_type=None): """ This funcction returns all the albums from a give artist_url using the US market :param artist_url - spotify artist url :param album_type - the type of album to fetch (ex: single) the default is - a standard album + all albums :param return - the album from the artist """ @@ -195,7 +195,7 @@ def write_all_albums_from_artist(artist_url, text_file=None): album_base_url = "https://open.spotify.com/album/" # fetching all default albums - albums = fetch_albums_from_artist(artist_url) + albums = fetch_albums_from_artist(artist_url, album_type=None) # if no file if given, the default save file is in the current working # directory with the name of the artist @@ -207,13 +207,6 @@ def write_all_albums_from_artist(artist_url, text_file=None): log.info("Fetching album: " + album["name"]) write_album(album_base_url + album["id"], text_file=text_file) - # fetching all single albums - singles = fetch_albums_from_artist(artist_url, album_type="single") - - for single in singles: - log.info("Fetching single: " + single["name"]) - write_album(album_base_url + single["id"], text_file=text_file) - def write_album(album_url, text_file=None): album = fetch_album(album_url) From 1d2b43a5f91c97d9f22e5d7b8b26ca214bf16153 Mon Sep 17 00:00:00 2001 From: Ritiek Malhotra Date: Mon, 4 Feb 2019 15:27:04 +0530 Subject: [PATCH 2/3] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 95c05cb..02668db 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - ### Changed +- Fetch all artist albums by default instead of only fetching the "album" type ([@ritiek](https://github.com/ritiek)) (#493) - Option `-f` (`--folder`) is used when exporting text files using `-p` (`--playlist`) for playlists or `-b` (`--album`) for albums ([@Silverfeelin](https://github.com/Silverfeelin)) (#476) - Use first artist from album object for album artist ([@tillhainbach](https://github.com/tillhainbach)) From 925521aa3bb28295635686fa8901e04e8bd40616 Mon Sep 17 00:00:00 2001 From: Ritiek Malhotra Date: Mon, 4 Feb 2019 20:18:01 +0530 Subject: [PATCH 3/3] Fix tests for now --- test/test_spotify_tools.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/test_spotify_tools.py b/test/test_spotify_tools.py index 671f752..6ed6d03 100644 --- a/test/test_spotify_tools.py +++ b/test/test_spotify_tools.py @@ -113,7 +113,8 @@ class TestFetchAlbumsFromArtist: return albums def test_len(self, albums_from_artist_fixture): - assert len(albums_from_artist_fixture) == 18 + # TODO: Mock this test (failed in #493) + assert len(albums_from_artist_fixture) == 52 def test_zeroth_album_name(self, albums_from_artist_fixture): assert albums_from_artist_fixture[0]["name"] == "Revolution Radio" @@ -128,11 +129,9 @@ class TestFetchAlbumsFromArtist: assert albums_from_artist_fixture[0]["total_tracks"] == 12 -# XXX: Mock this test off if it fails in future +# TODO: Mock this test (failed in #493) def test_write_all_albums_from_artist(tmpdir): - # current number of tracks on spotify since as of 10/10/2018 - # in US market only - expect_tracks = 49 + expect_tracks = 282 text_file = os.path.join(str(tmpdir), "test_ab.txt") spotify_tools.write_all_albums_from_artist( "https://open.spotify.com/artist/4dpARuHxo51G3z768sgnrY", text_file