Merge branch 'all-artists-test' into 'main'

option to download by followed artists

See merge request team-zotify/zotify!7
This commit is contained in:
Not Logykk 2022-03-28 20:48:46 +00:00
commit 5782b69c3d
7 changed files with 31 additions and 5 deletions

View File

@ -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

View File

@ -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.
```

View File

@ -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,

View File

@ -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.')

View File

@ -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:

View File

@ -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'

View File

@ -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..."):