diff --git a/CHANGELOG.md b/CHANGELOG.md index c7c3875..20ba0e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## v0.6.6 +- Added `-f` / `--followed` option to download every song by all of your followed artists + ## v0.6.5 - Implemented more stable fix for bug still persisting after v0.6.4 diff --git a/README.md b/README.md index fd3f196..dcb75b1 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ Basic options: -d, --download Download all tracks/alumbs/playlists URLs from the specified file -p, --playlist Downloads a saved playlist from your account -l, --liked Downloads all the liked songs from your account + -f, --followed Downloads all songs by all artists you follow -s, --search Searches for specified track, album, artist or playlist, loads search prompt if none are given. ``` diff --git a/setup.py b/setup.py index 45a0937..2f60251 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ README = (HERE / "README.md").read_text() # This call to setup() does all the work setup( name="zotify", - version="0.6.5", + version="0.6.6", author="Zotify Contributors", description="A music and podcast downloader.", long_description=README, diff --git a/zotify/__main__.py b/zotify/__main__.py index 11a2c3f..81374e7 100644 --- a/zotify/__main__.py +++ b/zotify/__main__.py @@ -36,6 +36,10 @@ def main(): dest='liked_songs', action='store_true', help='Downloads all the liked songs from your account.') + group.add_argument('-f', '--followed', + dest='followed_artists', + action='store_true', + help='Downloads all the songs from all your followed artists.') group.add_argument('-p', '--playlist', action='store_true', help='Downloads a saved playlist from your account.') diff --git a/zotify/app.py b/zotify/app.py index 131256d..9f61b57 100644 --- a/zotify/app.py +++ b/zotify/app.py @@ -9,7 +9,7 @@ from zotify.loader import Loader from zotify.playlist import get_playlist_songs, get_playlist_info, download_from_user_playlist, download_playlist from zotify.podcast import download_episode, get_show_episodes from zotify.termoutput import Printer, PrintChannel -from zotify.track import download_track, get_saved_tracks +from zotify.track import download_track, get_saved_tracks, get_followed_artists from zotify.utils import splash, split_input, regex_input_for_urls from zotify.zotify import Zotify @@ -59,12 +59,17 @@ def client(args) -> None: else: download_track('liked', song[TRACK][ID]) return + + if args.followed_artists: + for artist in get_followed_artists(): + download_artist_albums(artist) + return if args.search: if args.search == ' ': search_text = '' while len(search_text) == 0: - search_text = input('Enter search or URL: ') + search_text = input('Enter search: ') search(search_text) else: if not download_from_urls([args.search]): @@ -74,7 +79,7 @@ def client(args) -> None: else: search_text = '' while len(search_text) == 0: - search_text = input('Enter search or URL: ') + search_text = input('Enter search: ') search(search_text) def download_from_urls(urls: list[str]) -> bool: diff --git a/zotify/const.py b/zotify/const.py index 59c7d43..ae63567 100644 --- a/zotify/const.py +++ b/zotify/const.py @@ -1,3 +1,5 @@ +FOLLOWED_ARTISTS_URL = 'https://api.spotify.com/v1/me/following?type=artist' + SAVED_TRACKS_URL = 'https://api.spotify.com/v1/me/tracks' TRACKS_URL = 'https://api.spotify.com/v1/tracks' diff --git a/zotify/track.py b/zotify/track.py index 20633ae..a9f9f42 100644 --- a/zotify/track.py +++ b/zotify/track.py @@ -9,7 +9,8 @@ from librespot.metadata import TrackId import ffmpy from zotify.const import TRACKS, ALBUM, GENRES, NAME, ITEMS, DISC_NUMBER, TRACK_NUMBER, IS_PLAYABLE, ARTISTS, IMAGES, URL, \ - RELEASE_DATE, ID, TRACKS_URL, SAVED_TRACKS_URL, TRACK_STATS_URL, CODEC_MAP, EXT_MAP, DURATION_MS, HREF + RELEASE_DATE, ID, TRACKS_URL, FOLLOWED_ARTISTS_URL, SAVED_TRACKS_URL, TRACK_STATS_URL, CODEC_MAP, EXT_MAP, DURATION_MS, \ + HREF, ARTISTS from zotify.termoutput import Printer, PrintChannel from zotify.utils import fix_filename, set_audio_tags, set_music_thumbnail, create_download_directory, \ get_directory_song_ids, add_to_directory_song_ids, get_previously_downloaded, add_to_archive, fmt_seconds @@ -35,6 +36,16 @@ def get_saved_tracks() -> list: return songs +def get_followed_artists() -> list: + """ Returns user's followed artists """ + artists = [] + resp = Zotify.invoke_url(FOLLOWED_ARTISTS_URL)[1] + for artist in resp[ARTISTS][ITEMS]: + artists.append(artist[ID]) + + return artists + + def get_song_info(song_id) -> Tuple[List[str], List[Any], str, str, Any, Any, Any, Any, Any, Any, int]: """ Retrieves metadata for downloaded songs """ with Loader(PrintChannel.PROGRESS_INFO, "Fetching track information..."):