mirror of
				https://github.com/THIS-IS-NOT-A-BACKUP/zspotify.git
				synced 2025-11-03 21:10:34 +00:00 
			
		
		
		
	Added an option to select a range of playlist id's to download
This commit is contained in:
		
							parent
							
								
									a63d8adb72
								
							
						
					
					
						commit
						45a99cb3aa
					
				
							
								
								
									
										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
 | 
				
			||||||
@ -581,9 +581,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)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -592,14 +604,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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user