mirror of
https://github.com/THIS-IS-NOT-A-BACKUP/zspotify.git
synced 2024-11-29 19:24:34 +01:00
Merge pull request #48 from maxiimillian/feature-multiple-playlists
Added an option to select a range of playlist id's to download
This commit is contained in:
commit
4c29263e8a
46
zspotify.py
46
zspotify.py
@ -31,7 +31,7 @@ ROOT_PODCAST_PATH = "ZSpotify Podcasts/"
|
|||||||
|
|
||||||
SKIP_EXISTING_FILES = True
|
SKIP_EXISTING_FILES = True
|
||||||
|
|
||||||
MUSIC_FORMAT = "mp3" # or "ogg"
|
MUSIC_FORMAT = "ogg" # or "ogg"
|
||||||
RAW_AUDIO_AS_IS = False # set to True if you wish to just save the raw audio
|
RAW_AUDIO_AS_IS = False # set to True if you wish to just save the raw audio
|
||||||
|
|
||||||
FORCE_PREMIUM = False # set to True if not detecting your premium account automatically
|
FORCE_PREMIUM = False # set to True if not detecting your premium account automatically
|
||||||
@ -619,9 +619,21 @@ def download_album(album):
|
|||||||
download_track(track['id'], artist + " - " + album_name + "/")
|
download_track(track['id'], artist + " - " + album_name + "/")
|
||||||
print("\n")
|
print("\n")
|
||||||
|
|
||||||
|
def download_playlist(playlists, playlist_choice):
|
||||||
|
"""Downloads all the songs from a playlist"""
|
||||||
|
token = SESSION.tokens().get("user-read-email")
|
||||||
|
|
||||||
|
playlist_songs = get_playlist_songs(
|
||||||
|
token, playlists[int(playlist_choice) - 1]['id'])
|
||||||
|
|
||||||
|
for song in playlist_songs:
|
||||||
|
if song['track']['id'] is not None:
|
||||||
|
download_track(song['track']['id'], sanitize_data(
|
||||||
|
playlists[int(playlist_choice) - 1]['name'].strip()) + "/")
|
||||||
|
print("\n")
|
||||||
|
|
||||||
def download_from_user_playlist():
|
def download_from_user_playlist():
|
||||||
""" Downloads songs from users playlist """
|
""" Select which playlist(s) to download """
|
||||||
token = SESSION.tokens().get("user-read-email")
|
token = SESSION.tokens().get("user-read-email")
|
||||||
playlists = get_all_playlists(token)
|
playlists = get_all_playlists(token)
|
||||||
|
|
||||||
@ -630,14 +642,28 @@ def download_from_user_playlist():
|
|||||||
print(str(count) + ": " + playlist['name'].strip())
|
print(str(count) + ": " + playlist['name'].strip())
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
playlist_choice = input("SELECT A PLAYLIST BY ID: ")
|
print("\n> SELECT A PLAYLIST BY ID")
|
||||||
playlist_songs = get_playlist_songs(
|
print("> SELECT A RANGE BY ADDING A DASH BETWEEN BOTH ID's")
|
||||||
token, playlists[int(playlist_choice) - 1]['id'])
|
print("> For example, typing 10 to get one playlist or 10-20 to get\nevery playlist from 10-20 (inclusive)\n")
|
||||||
for song in playlist_songs:
|
|
||||||
if song['track']['id'] is not None:
|
playlist_choices = input("ID(s): ").split("-")
|
||||||
download_track(song['track']['id'], sanitize_data(
|
|
||||||
playlists[int(playlist_choice) - 1]['name'].strip()) + "/")
|
if len(playlist_choices) == 1:
|
||||||
print("\n")
|
download_playlist(playlists, playlist_choices[0])
|
||||||
|
else:
|
||||||
|
start = int(playlist_choices[0])
|
||||||
|
end = int(playlist_choices[1])+1
|
||||||
|
|
||||||
|
print(f"Downloading from {start} to {end}...")
|
||||||
|
|
||||||
|
for playlist in range(start, end):
|
||||||
|
download_playlist(playlists, playlist)
|
||||||
|
|
||||||
|
print("\n**All playlists have been downloaded**\n")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Core functions here
|
# Core functions here
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user