mirror of
				https://github.com/THIS-IS-NOT-A-BACKUP/zspotify.git
				synced 2025-11-04 05:20:34 +00:00 
			
		
		
		
	remade changes after merging with main
This commit is contained in:
		
							parent
							
								
									d69fb8e754
								
							
						
					
					
						commit
						132c235bdb
					
				@ -28,14 +28,14 @@ Python packages:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
\*\*Git can be installed via apt for Debian-based distros or by downloading the binaries from [git-scm.com](https://git-scm.com/download/win) for Windows.
 | 
					\*\*Git can be installed via apt for Debian-based distros or by downloading the binaries from [git-scm.com](https://git-scm.com/download/win) for Windows.
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
Command line usage:
 | 
					Basic command line usage:
 | 
				
			||||||
  python zspotify                                      Loads search prompt to find then download a specific track, album or playlist
 | 
					  python zspotify <track/album/playlist/episode/artist url>   Downloads the track, album, playlist or podcast episode specified as a command line argument. If an artist url is given, all albums by specified artist will be downloaded.
 | 
				
			||||||
  python zspotify <track/album/playlist/episode url>   Downloads the track, album, playlist or podcast episode specified as a command line argument
 | 
					 | 
				
			||||||
  python zspotify <artist url>                         Downloads all albums by specified artist
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
Extra command line options:
 | 
					Extra command line options:
 | 
				
			||||||
  -p, --playlist       Downloads a saved playlist from your account
 | 
					  -p, --playlist       Downloads a saved playlist from your account
 | 
				
			||||||
  -ls, --liked-songs   Downloads all the liked songs from your account
 | 
					  -ls, --liked-songs   Downloads all the liked songs from your account
 | 
				
			||||||
 | 
					  -s, --search         Loads search prompt to find then download a specific track, album or playlist
 | 
				
			||||||
 | 
					  -ns, --no-splash     Suppress the splash screen when loading.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Options that can be configured in zs_config.json:
 | 
					Options that can be configured in zs_config.json:
 | 
				
			||||||
  ROOT_PATH           Change this path if you don't like the default directory where ZSpotify saves the music
 | 
					  ROOT_PATH           Change this path if you don't like the default directory where ZSpotify saves the music
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,34 @@
 | 
				
			|||||||
 | 
					import argparse
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from app import client
 | 
					from app import client
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == '__main__':
 | 
					if __name__ == '__main__':
 | 
				
			||||||
    client()
 | 
					    parser = argparse.ArgumentParser(prog='zspotify',
 | 
				
			||||||
 | 
					        description='A Spotify downloader needing only a python interpreter and ffmpeg.')
 | 
				
			||||||
 | 
					    parser.add_argument('-ns', '--no-splash',
 | 
				
			||||||
 | 
					                        action='store_true',
 | 
				
			||||||
 | 
					                        help='Suppress the splash screen when loading.')
 | 
				
			||||||
 | 
					    group = parser.add_mutually_exclusive_group(required=True)
 | 
				
			||||||
 | 
					    group.add_argument('url',
 | 
				
			||||||
 | 
					                       type=str,
 | 
				
			||||||
 | 
					                       default='',
 | 
				
			||||||
 | 
					                       nargs='?',
 | 
				
			||||||
 | 
					                       help='Downloads the track, album, playlist, podcast episode, or all albums by an artist from a url.')
 | 
				
			||||||
 | 
					    group.add_argument('-ls', '--liked-songs',
 | 
				
			||||||
 | 
					                       dest='liked_songs',
 | 
				
			||||||
 | 
					                       action='store_true',
 | 
				
			||||||
 | 
					                       help='Downloads all the liked songs from your account.')
 | 
				
			||||||
 | 
					    group.add_argument('-p', '--playlist',
 | 
				
			||||||
 | 
					                       action='store_true',
 | 
				
			||||||
 | 
					                       help='Downloads a saved playlist from your account.')
 | 
				
			||||||
 | 
					    group.add_argument('-s', '--search',
 | 
				
			||||||
 | 
					                       dest='search_spotify',
 | 
				
			||||||
 | 
					                       action='store_true',
 | 
				
			||||||
 | 
					                       help='Loads search prompt to find then download a specific track, album or playlist')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    parser.set_defaults(func=client)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    args = parser.parse_args()
 | 
				
			||||||
 | 
					    args.func(args)
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,3 @@
 | 
				
			|||||||
import sys
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
from librespot.audio.decoders import AudioQuality
 | 
					from librespot.audio.decoders import AudioQuality
 | 
				
			||||||
from tabulate import tabulate
 | 
					from tabulate import tabulate
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -15,30 +13,24 @@ from zspotify import ZSpotify
 | 
				
			|||||||
SEARCH_URL = 'https://api.spotify.com/v1/search'
 | 
					SEARCH_URL = 'https://api.spotify.com/v1/search'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def client() -> None:
 | 
					def client(args) -> None:
 | 
				
			||||||
    """ Connects to spotify to perform query's and get songs to download """
 | 
					    """ Connects to spotify to perform query's and get songs to download """
 | 
				
			||||||
    ZSpotify()
 | 
					    ZSpotify()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if not args.no_splash:
 | 
				
			||||||
        splash()
 | 
					        splash()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ZSpotify.check_premium():
 | 
					    if ZSpotify.check_premium():
 | 
				
			||||||
 | 
					        if not args.no_splash:
 | 
				
			||||||
            print('[ DETECTED PREMIUM ACCOUNT - USING VERY_HIGH QUALITY ]\n\n')
 | 
					            print('[ DETECTED PREMIUM ACCOUNT - USING VERY_HIGH QUALITY ]\n\n')
 | 
				
			||||||
        ZSpotify.DOWNLOAD_QUALITY = AudioQuality.VERY_HIGH
 | 
					        ZSpotify.DOWNLOAD_QUALITY = AudioQuality.VERY_HIGH
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
 | 
					        if not args.no_splash:
 | 
				
			||||||
            print('[ DETECTED FREE ACCOUNT - USING HIGH QUALITY ]\n\n')
 | 
					            print('[ DETECTED FREE ACCOUNT - USING HIGH QUALITY ]\n\n')
 | 
				
			||||||
        ZSpotify.DOWNLOAD_QUALITY = AudioQuality.HIGH
 | 
					        ZSpotify.DOWNLOAD_QUALITY = AudioQuality.HIGH
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if len(sys.argv) > 1:
 | 
					    if args.url:
 | 
				
			||||||
        if sys.argv[1] == '-p' or sys.argv[1] == '--playlist':
 | 
					        track_id, album_id, playlist_id, episode_id, show_id, artist_id = regex_input_for_urls(args.url)
 | 
				
			||||||
            download_from_user_playlist()
 | 
					 | 
				
			||||||
        elif sys.argv[1] == '-ls' or sys.argv[1] == '--liked-songs':
 | 
					 | 
				
			||||||
            for song in get_saved_tracks():
 | 
					 | 
				
			||||||
                if not song[TRACK][NAME]:
 | 
					 | 
				
			||||||
                    print('###   SKIPPING:  SONG DOES NOT EXIST ON SPOTIFY ANYMORE   ###')
 | 
					 | 
				
			||||||
                else:
 | 
					 | 
				
			||||||
                    download_track(song[TRACK][ID], 'Liked Songs/')
 | 
					 | 
				
			||||||
                print('\n')
 | 
					 | 
				
			||||||
        else:
 | 
					 | 
				
			||||||
            track_id, album_id, playlist_id, episode_id, show_id, artist_id = regex_input_for_urls(sys.argv[1])
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if track_id is not None:
 | 
					        if track_id is not None:
 | 
				
			||||||
            download_track(track_id)
 | 
					            download_track(track_id)
 | 
				
			||||||
@ -59,7 +51,18 @@ def client() -> None:
 | 
				
			|||||||
            for episode in get_show_episodes(show_id):
 | 
					            for episode in get_show_episodes(show_id):
 | 
				
			||||||
                download_episode(episode)
 | 
					                download_episode(episode)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if args.playlist:
 | 
				
			||||||
 | 
					        download_from_user_playlist()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if args.liked_songs:
 | 
				
			||||||
 | 
					        for song in get_saved_tracks():
 | 
				
			||||||
 | 
					            if not song[TRACK][NAME]:
 | 
				
			||||||
 | 
					                print('###   SKIPPING:  SONG DOES NOT EXIST ON SPOTIFY ANYMORE   ###')
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
 | 
					                download_track(song[TRACK][ID], 'Liked Songs/')
 | 
				
			||||||
 | 
					            print('\n')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if args.search_spotify:
 | 
				
			||||||
        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 or URL: ')
 | 
				
			||||||
@ -261,4 +264,3 @@ def search(search_term):
 | 
				
			|||||||
                        download_artist_albums(dic[ID])
 | 
					                        download_artist_albums(dic[ID])
 | 
				
			||||||
                    else:
 | 
					                    else:
 | 
				
			||||||
                        download_playlist(dic)
 | 
					                        download_playlist(dic)
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user