mirror of
				https://github.com/KevinMidboe/spotify-downloader.git
				synced 2025-10-29 18:00:15 +00:00 
			
		
		
		
	Search format enhancements
This commit is contained in:
		| @@ -31,14 +31,16 @@ All the below changes were made as a part of #690. | ||||
| - Display a combined *download & encode* progress bar. | ||||
|  | ||||
| ### Changed | ||||
| - **[Breaking]** Tracks are now downloaded in the current working directory (instead of Music directory) | ||||
|   by default. | ||||
| - **[Breaking]** Tracks are now downloaded in the current working directory (instead of | ||||
|   user's Music directory) by default. | ||||
| - **[Breaking]** Short for `--album` is now `-a` instead of `-b`. | ||||
| - **[Breaking]** Short for `--all-albums` is now `-aa` instead of `-ab`. | ||||
| - Allow "&" character in filenames. | ||||
| - **[Breaking]** Merge parameters `-ff` and `-f` to `-f` (`--output-file`). | ||||
| - **[Breaking]** Do not prefix formats with a dot when specifying `-i` and `-o` parameters | ||||
|   Such as `-o .mp3` is now written as `-o mp3`. | ||||
| - **[Breaking]** Search format now uses hyphen for word break instead of underscore. Such as | ||||
|   `-sf "{artist} - {track_name}"` is now written as `-sf "{artist} - {track-name}"`. | ||||
| - Partial re-write and internal API refactor. | ||||
| - Enhance debug log output readability. | ||||
| - Internally adapt to latest changes made in Spotipy library. | ||||
|   | ||||
| @@ -153,6 +153,7 @@ def get_arguments(argv=None, base_config_file=spotdl.config.default_config_file) | ||||
|         default=config["output_file"], | ||||
|         help="path where to write the downloaded track to, special tags " | ||||
|         "are to be surrounded by curly braces. Possible tags: " | ||||
|         # TODO: Add possible tags | ||||
|         # "{}".format([spotdl.util.formats[x] for x in spotdl.util.formats]), | ||||
|     ) | ||||
|     parser.add_argument( | ||||
| @@ -167,6 +168,7 @@ def get_arguments(argv=None, base_config_file=spotdl.config.default_config_file) | ||||
|         default=config["search_format"], | ||||
|         help="search format to search for on YouTube, special tags " | ||||
|         "are to be surrounded by curly braces. Possible tags: " | ||||
|         # TODO: Add possible tags | ||||
|         # "{}".format([spotdl.util.formats[x] for x in spotdl.util.formats]), | ||||
|     ) | ||||
|     parser.add_argument( | ||||
| @@ -198,7 +200,8 @@ def get_arguments(argv=None, base_config_file=spotdl.config.default_config_file) | ||||
|         "-ns", | ||||
|         "--no-spaces", | ||||
|         default=config["no_spaces"], | ||||
|         help="replace spaces with underscores in file names", | ||||
|         help="replace spaces in metadata values with underscores when " | ||||
|         "generating filenames", | ||||
|         action="store_true", | ||||
|     ) | ||||
|     parser.add_argument( | ||||
|   | ||||
| @@ -111,7 +111,7 @@ class YouTubeSearch: | ||||
|     def search(self, query, limit=10, retries=5): | ||||
|         """ Search and scrape YouTube to return a list of matching videos. """ | ||||
|         search_url = self.generate_search_url(query) | ||||
|         logger.debug('Fetching YouTube results for "{}".'.format(search_url)) | ||||
|         logger.debug('Fetching YouTube results for "{}" at "{}".'.format(query, search_url)) | ||||
|         html = self._fetch_response_html(search_url) | ||||
|         videos = self._fetch_search_results(html, limit=limit) | ||||
|         to_retry = retries > 0 and self._is_server_side_invalid_response(videos, html) | ||||
|   | ||||
| @@ -181,10 +181,6 @@ class MetadataSearch: | ||||
|     def _on_youtube_and_spotify_for_type_spotify(self): | ||||
|         logger.debug("Extracting YouTube and Spotify metadata for input Spotify URI.") | ||||
|         spotify_metadata = self._on_spotify_for_type_spotify(self.track) | ||||
|         lyric_query = spotdl.metadata.format_string( | ||||
|             "{artist} - {track-name}", | ||||
|             spotify_metadata, | ||||
|         ) | ||||
|         search_query = spotdl.metadata.format_string(self.yt_search_format, spotify_metadata) | ||||
|         youtube_video = self._best_on_youtube_search_for_type_spotify(search_query) | ||||
|         youtube_metadata = self.providers["youtube"].from_url(youtube_video["url"]) | ||||
| @@ -197,7 +193,7 @@ class MetadataSearch: | ||||
|     def _on_youtube_and_spotify_for_type_youtube(self): | ||||
|         logger.debug("Extracting YouTube and Spotify metadata for input YouTube URL.") | ||||
|         youtube_metadata = self._on_youtube_for_type_youtube(self.track) | ||||
|         search_query = spotdl.metadata.format_string(self.yt_search_format, youtube_metadata) | ||||
|         search_query = spotdl.metadata.format_string("{track-name}", youtube_metadata) | ||||
|         spotify_metadata = self._on_spotify_for_type_query(search_query) | ||||
|         metadata = spotdl.util.merge( | ||||
|             youtube_metadata, | ||||
| @@ -208,7 +204,6 @@ class MetadataSearch: | ||||
|     def _on_youtube_and_spotify_for_type_query(self): | ||||
|         logger.debug("Extracting YouTube and Spotify metadata for input track query.") | ||||
|         search_query = self.track | ||||
|         lyric_query = search_query | ||||
|         # Make use of threads here to search on both YouTube & Spotify | ||||
|         # at the same time. | ||||
|         spotify_metadata = spotdl.util.ThreadWithReturnValue( | ||||
| @@ -226,10 +221,6 @@ class MetadataSearch: | ||||
|     def _on_youtube_for_type_spotify(self): | ||||
|         logger.debug("Extracting YouTube metadata for input Spotify URI.") | ||||
|         spotify_metadata = self._on_spotify_for_type_spotify(self.track) | ||||
|         lyric_query = spotdl.metadata.format_string( | ||||
|             "{artist} - {track-name}", | ||||
|             spotify_metadata, | ||||
|         ) | ||||
|         search_query = spotdl.metadata.format_string(self.yt_search_format, spotify_metadata) | ||||
|         youtube_video = self._best_on_youtube_search_for_type_spotify(search_query) | ||||
|         youtube_metadata = self.providers["youtube"].from_url(youtube_video["url"]) | ||||
| @@ -249,7 +240,7 @@ class MetadataSearch: | ||||
|     def _on_spotify_for_type_youtube(self, url): | ||||
|         logger.debug("Extracting Spotify metadata for input YouTube URL.") | ||||
|         youtube_metadata = self.providers["youtube"].from_url(url) | ||||
|         search_query = spotdl.metadata.format_string(self.yt_search_format, youtube_metadata) | ||||
|         search_query = spotdl.metadata.format_string("{track-name}", youtube_metadata) | ||||
|         spotify_metadata = self.providers["spotify"].from_query(search_query) | ||||
|         return spotify_metadata | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user