def test_outdated_version(fake_process, capsys): fake_process.register_subprocess(["ffmpeg", "-version"], stdout=outdated_version) assert ffmpeg.has_correct_version() == False output, error = capsys.readouterr() assert "Your FFmpeg installation is too old (1.0), please update to 4.2+\n" in error
def test_invalid_version(fake_process, capsys): fake_process.register_subprocess(["ffmpeg", "-version"], stdout=invalid_version) assert ffmpeg.has_correct_version() == False output, error = capsys.readouterr() assert "Your FFmpeg version couldn't be detected" in error
def console_entry_point(): """ This is where all the console processing magic happens. Its super simple, rudimentary even but, it's dead simple & it works. """ arguments = parse_arguments() args_dict = vars(arguments) if (ffmpeg.has_correct_version(arguments.ignore_ffmpeg_version, arguments.ffmpeg or "ffmpeg") is False): sys.exit(1) for request in arguments.query: if "saved" == request and not arguments.userAuth: arguments.userAuth = True print( "Detected 'saved' in command line, but no --user-auth flag. Enabling Anyways." ) print("Please Log In...") SpotifyClient.init( client_id="5f573c9620494bae87890c0f08a60293", client_secret="212476d9b0f3472eaa762d90b19b0ba8", user_auth=arguments.userAuth, ) if arguments.path: if not os.path.isdir(arguments.path): sys.exit("The output directory doesn't exist.") print(f"Will download to: {os.path.abspath(arguments.path)}") os.chdir(arguments.path) with DownloadManager(args_dict) as downloader: if not arguments.debug_termination: def gracefulExit(signal, frame): downloader.displayManager.close() sys.exit(0) signal.signal(signal.SIGINT, gracefulExit) signal.signal(signal.SIGTERM, gracefulExit) songObjList = [] for request in arguments.query: if request.endswith(".spotdlTrackingFile"): print("Preparing to resume download...") downloader.resume_download_from_tracking_file(request) else: songObjList.extend( songGatherer.from_query(request, arguments.format)) # linefeed to visually separate output for each query print() if len(songObjList) > 0: downloader.download_multiple_songs(songObjList)
def console_entry_point(): ''' This is where all the console processing magic happens. Its super simple, rudimentary even but, it's dead simple & it works. ''' arguments = parse_arguments() if ffmpeg.has_correct_version(arguments.ignore_ffmpeg_version, arguments.ffmpeg or "ffmpeg") is False: sys.exit(1) SpotifyClient.init(client_id='5f573c9620494bae87890c0f08a60293', client_secret='212476d9b0f3472eaa762d90b19b0ba8') if arguments.path: if not os.path.isdir(arguments.path): sys.exit("The output directory doesn't exist.") print(f"Will download to: {os.path.abspath(arguments.path)}") os.chdir(arguments.path) with DownloadManager(arguments.ffmpeg) as downloader: if not arguments.debug_termination: def gracefulExit(signal, frame): downloader.displayManager.close() sys.exit(0) signal.signal(signal.SIGINT, gracefulExit) signal.signal(signal.SIGTERM, gracefulExit) for request in arguments.url: if os.path.isfile(request): print('Processing file ...') try: with open(request) as input: for line in input.readlines(): process_request(downloader, line) except Exception as e: print(e) else: process_request(downloader, request)
def test_nightly_version(fake_process): fake_process.register_subprocess(["ffmpeg", "-version"], stdout=nightly_version) assert ffmpeg.has_correct_version() == True
def console_entry_point(): ''' This is where all the console processing magic happens. Its super simple, rudimentary even but, it's dead simple & it works. ''' arguments = parse_arguments() if ffmpeg.has_correct_version(arguments.ignore_ffmpeg_version) is False: sys.exit(1) SpotifyClient.init(client_id='5f573c9620494bae87890c0f08a60293', client_secret='212476d9b0f3472eaa762d90b19b0ba8') if arguments.path: if not os.path.isdir(arguments.path): sys.exit("The output directory doesn't exist.") print(f"Will download to: {os.path.abspath(arguments.path)}") os.chdir(arguments.path) with DownloadManager() as downloader: for request in arguments.url: if 'open.spotify.com' in request and 'track' in request: print('Fetching Song...') song = SongObj.from_url(request) if song.get_youtube_link() is not None: downloader.download_single_song(song) else: print( 'Skipping %s (%s) as no match could be found on youtube' % (song.get_song_name(), request)) elif 'open.spotify.com' in request and 'album' in request: print('Fetching Album...') songObjList = get_album_tracks(request) downloader.download_multiple_songs(songObjList) elif 'open.spotify.com' in request and 'playlist' in request: print('Fetching Playlist...') songObjList = get_playlist_tracks(request) downloader.download_multiple_songs(songObjList) elif 'open.spotify.com' in request and 'artist' in request: print('Fetching artist...') artistObjList = get_artist_tracks(request) downloader.download_multiple_songs(artistObjList) elif request.endswith('.spotdlTrackingFile'): print('Preparing to resume download...') downloader.resume_download_from_tracking_file(request) else: print('Searching for song "%s"...' % request) try: song = search_for_song(request) downloader.download_single_song(song) except Exception as e: print(e)
def console_entry_point(): """ This is where all the console processing magic happens. Its super simple, rudimentary even but, it's dead simple & it works. """ # If -v parameter is specified print version and exit if len(sys.argv) >= 2 and sys.argv[1] in ["-v", "--version"]: version = pkg_resources.require("spotdl")[0].version print(version) sys.exit(0) # Parser arguments arguments = parse_arguments() # Convert arguments to dict args_dict = vars(arguments) # Check if ffmpeg has correct version, if not exit if (ffmpeg.has_correct_version(arguments.ignore_ffmpeg_version, arguments.ffmpeg or "ffmpeg") is False): sys.exit(1) if "saved" in arguments.query and not arguments.user_auth: arguments.user_auth = True print( "Detected 'saved' in command line, but no --user-auth flag. Enabling Anyways." ) print("Please Log In...") # Initialize spotify client SpotifyClient.init( client_id="5f573c9620494bae87890c0f08a60293", client_secret="212476d9b0f3472eaa762d90b19b0ba8", user_auth=arguments.user_auth, ) # Change directory if user specified correct output path if arguments.output: if not os.path.isdir(arguments.output): sys.exit("The output directory doesn't exist.") print(f"Will download to: {os.path.abspath(arguments.output)}") os.chdir(arguments.output) # Start download manager with DownloadManager(args_dict) as downloader: if not arguments.debug_termination: def graceful_exit(signal, frame): downloader.display_manager.close() sys.exit(0) signal.signal(signal.SIGINT, graceful_exit) signal.signal(signal.SIGTERM, graceful_exit) # Find tracking files in queries tracking_files = [ query for query in arguments.query if query.endswith(".spotdlTrackingFile") ] # Restart downloads for tracking_file in tracking_files: print("Preparing to resume download...") downloader.resume_download_from_tracking_file(tracking_file) # Get songs song_list = parse_query( arguments.query, arguments.output_format, arguments.use_youtube, arguments.generate_m3u, arguments.search_threads, ) # Start downloading if len(song_list) > 0: downloader.download_multiple_songs(song_list)