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:
commit
5782b69c3d
|
@ -1,5 +1,8 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v0.6.6
|
||||||
|
- Added `-f` / `--followed` option to download every song by all of your followed artists
|
||||||
|
|
||||||
## v0.6.5
|
## v0.6.5
|
||||||
- Implemented more stable fix for bug still persisting after v0.6.4
|
- Implemented more stable fix for bug still persisting after v0.6.4
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ Basic options:
|
||||||
-d, --download Download all tracks/alumbs/playlists URLs from the specified file
|
-d, --download Download all tracks/alumbs/playlists URLs from the specified file
|
||||||
-p, --playlist Downloads a saved playlist from your account
|
-p, --playlist Downloads a saved playlist from your account
|
||||||
-l, --liked Downloads all the liked songs 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.
|
-s, --search Searches for specified track, album, artist or playlist, loads search prompt if none are given.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -12,7 +12,7 @@ README = (HERE / "README.md").read_text()
|
||||||
# This call to setup() does all the work
|
# This call to setup() does all the work
|
||||||
setup(
|
setup(
|
||||||
name="zotify",
|
name="zotify",
|
||||||
version="0.6.5",
|
version="0.6.6",
|
||||||
author="Zotify Contributors",
|
author="Zotify Contributors",
|
||||||
description="A music and podcast downloader.",
|
description="A music and podcast downloader.",
|
||||||
long_description=README,
|
long_description=README,
|
||||||
|
|
|
@ -36,6 +36,10 @@ def main():
|
||||||
dest='liked_songs',
|
dest='liked_songs',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help='Downloads all the liked songs from your account.')
|
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',
|
group.add_argument('-p', '--playlist',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help='Downloads a saved playlist from your account.')
|
help='Downloads a saved playlist from your account.')
|
||||||
|
|
|
@ -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.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.podcast import download_episode, get_show_episodes
|
||||||
from zotify.termoutput import Printer, PrintChannel
|
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.utils import splash, split_input, regex_input_for_urls
|
||||||
from zotify.zotify import Zotify
|
from zotify.zotify import Zotify
|
||||||
|
|
||||||
|
@ -59,12 +59,17 @@ def client(args) -> None:
|
||||||
else:
|
else:
|
||||||
download_track('liked', song[TRACK][ID])
|
download_track('liked', song[TRACK][ID])
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if args.followed_artists:
|
||||||
|
for artist in get_followed_artists():
|
||||||
|
download_artist_albums(artist)
|
||||||
|
return
|
||||||
|
|
||||||
if args.search:
|
if args.search:
|
||||||
if args.search == ' ':
|
if args.search == ' ':
|
||||||
search_text = ''
|
search_text = ''
|
||||||
while len(search_text) == 0:
|
while len(search_text) == 0:
|
||||||
search_text = input('Enter search or URL: ')
|
search_text = input('Enter search: ')
|
||||||
search(search_text)
|
search(search_text)
|
||||||
else:
|
else:
|
||||||
if not download_from_urls([args.search]):
|
if not download_from_urls([args.search]):
|
||||||
|
@ -74,7 +79,7 @@ def client(args) -> None:
|
||||||
else:
|
else:
|
||||||
search_text = ''
|
search_text = ''
|
||||||
while len(search_text) == 0:
|
while len(search_text) == 0:
|
||||||
search_text = input('Enter search or URL: ')
|
search_text = input('Enter search: ')
|
||||||
search(search_text)
|
search(search_text)
|
||||||
|
|
||||||
def download_from_urls(urls: list[str]) -> bool:
|
def download_from_urls(urls: list[str]) -> bool:
|
||||||
|
|
|
@ -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'
|
SAVED_TRACKS_URL = 'https://api.spotify.com/v1/me/tracks'
|
||||||
|
|
||||||
TRACKS_URL = 'https://api.spotify.com/v1/tracks'
|
TRACKS_URL = 'https://api.spotify.com/v1/tracks'
|
||||||
|
|
|
@ -9,7 +9,8 @@ from librespot.metadata import TrackId
|
||||||
import ffmpy
|
import ffmpy
|
||||||
|
|
||||||
from zotify.const import TRACKS, ALBUM, GENRES, NAME, ITEMS, DISC_NUMBER, TRACK_NUMBER, IS_PLAYABLE, ARTISTS, IMAGES, URL, \
|
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.termoutput import Printer, PrintChannel
|
||||||
from zotify.utils import fix_filename, set_audio_tags, set_music_thumbnail, create_download_directory, \
|
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
|
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
|
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]:
|
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 """
|
""" Retrieves metadata for downloaded songs """
|
||||||
with Loader(PrintChannel.PROGRESS_INFO, "Fetching track information..."):
|
with Loader(PrintChannel.PROGRESS_INFO, "Fetching track information..."):
|
||||||
|
|
Loading…
Reference in New Issue