mirror of
				https://github.com/THIS-IS-NOT-A-BACKUP/zspotify.git
				synced 2025-11-03 21:10:34 +00:00 
			
		
		
		
	added support for selecting multiple options in search
This commit is contained in:
		
							parent
							
								
									6a808b68b3
								
							
						
					
					
						commit
						b1df2c42d9
					
				
							
								
								
									
										28
									
								
								zspotify.py
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								zspotify.py
									
									
									
									
									
								
							@ -44,6 +44,8 @@ OVERRIDE_AUTO_WAIT = False
 | 
			
		||||
CHUNK_SIZE = 50000
 | 
			
		||||
 | 
			
		||||
# miscellaneous functions for general use
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def clear():
 | 
			
		||||
    """ Clear the console window """
 | 
			
		||||
    if platform.system() == "Windows":
 | 
			
		||||
@ -67,6 +69,20 @@ def sanitize_data(value):
 | 
			
		||||
    return value.replace("|", "-")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def split_input(selection):
 | 
			
		||||
    """ Returns a list of inputted strings """
 | 
			
		||||
    inputs = []
 | 
			
		||||
    if "-" in selection:
 | 
			
		||||
        for number in range(int(selection.split("-")[0]), int(selection.split("-")[1]) + 1):
 | 
			
		||||
            inputs.append(number)
 | 
			
		||||
        return inputs
 | 
			
		||||
    else:
 | 
			
		||||
        selections = selection.split(",")
 | 
			
		||||
        for i in selections:
 | 
			
		||||
            inputs.append(i.strip())
 | 
			
		||||
        return inputs
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def splash():
 | 
			
		||||
    """ Displays splash screen """
 | 
			
		||||
    print("=================================\n"
 | 
			
		||||
@ -366,8 +382,10 @@ def search(search_term):
 | 
			
		||||
    if len(tracks) + len(albums) + len(playlists) == 0:
 | 
			
		||||
        print("NO RESULTS FOUND - EXITING...")
 | 
			
		||||
    else:
 | 
			
		||||
        position = int(input("SELECT ITEM BY ID: "))
 | 
			
		||||
 | 
			
		||||
        selection = str(input("SELECT ITEM(S) BY ID: "))
 | 
			
		||||
        inputs = split_input(selection)
 | 
			
		||||
        for pos in inputs:
 | 
			
		||||
            position = int(pos)
 | 
			
		||||
            if position <= total_tracks:
 | 
			
		||||
                track_id = tracks[position - 1]["id"]
 | 
			
		||||
                download_track(track_id)
 | 
			
		||||
@ -376,7 +394,8 @@ def search(search_term):
 | 
			
		||||
            else:
 | 
			
		||||
                playlist_choice = playlists[position -
 | 
			
		||||
                                            total_tracks - total_albums - 1]
 | 
			
		||||
            playlist_songs = get_playlist_songs(token, playlist_choice['id'])
 | 
			
		||||
                playlist_songs = get_playlist_songs(
 | 
			
		||||
                    token, playlist_choice['id'])
 | 
			
		||||
                for song in playlist_songs:
 | 
			
		||||
                    if song['track']['id'] is not None:
 | 
			
		||||
                        download_track(song['track']['id'], sanitize_data(
 | 
			
		||||
@ -600,7 +619,8 @@ def download_track(track_id_str: str, extra_paths=""):
 | 
			
		||||
                            unit_divisor=1024
 | 
			
		||||
                    ) as bar:
 | 
			
		||||
                        for _ in range(int(total_size / CHUNK_SIZE) + 1):
 | 
			
		||||
                            bar.update(file.write(stream.input_stream.stream().read(CHUNK_SIZE)))
 | 
			
		||||
                            bar.update(file.write(
 | 
			
		||||
                                stream.input_stream.stream().read(CHUNK_SIZE)))
 | 
			
		||||
 | 
			
		||||
                    if not RAW_AUDIO_AS_IS:
 | 
			
		||||
                        convert_audio_format(filename)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user