From 1cf421960c0ef28d4f492dee49408a905d345bf4 Mon Sep 17 00:00:00 2001 From: Amit Lawanghare Date: Sat, 29 Dec 2018 00:35:24 -0800 Subject: [PATCH] Issue with Spotify-url and --no-metadata #452 (#454) * Applied a check on null result in case of no youtube search * Allow fetch metadata from spotify upon searching spotify-url and no-metadata * updated changes.md * Updated CHANGES.md as per suggestion * removed unnecessary bool hit Co-Authored-By: Amit-L * removed unnecessary bool hit, anti PEP 8 Co-Authored-By: Amit-L * resolved conflicts * Error shown no videos found * Dont to show any manual option for no result --- CHANGES.md | 3 +++ spotdl/youtube_tools.py | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 2de1c3f..47fc6be 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,9 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] ### Added +- Output informative message in case of no result found in YouTube search ([@Amit-L](https://github.com/Amit-L)) (#452) - Ability to pass multiple tracks with `-s` option ([@ritiek](https://github.com/ritiek)) (#442) ### Changed +- Allowed to fetch metadata from Spotify upon searching Spotify-URL and `--no-metadata` to gather YouTube custom-search fields ([@Amit-L](https://github.com/Amit-L)) (#452) - Change FFmpeg to use the built-in encoder `aac` instead of 3rd party `libfdk-aac` which does not ship with the apt package ([@ritiek](https://github.com/ritiek)) (#448) - Monkeypatch ever-changing network-relying tests ([@ritiek](https://github.com/ritiek)) (#448) @@ -18,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Refactored core downloading module ([@ritiek](https://github.com/ritiek)) (#410) ### Fixed +- Applied a check on result in case of search using Spotify-URL `--no-metadata` option ([@Amit-L](https://github.com/Amit-L)) (#452) - Included a missing `import spotipy` in downloader.py ([@ritiek](https://github.com/ritiek)) (#440) ## [1.1.0] - 2018-11-13 diff --git a/spotdl/youtube_tools.py b/spotdl/youtube_tools.py index 7fb8476..1cb4192 100644 --- a/spotdl/youtube_tools.py +++ b/spotdl/youtube_tools.py @@ -50,8 +50,10 @@ def match_video_and_metadata(track, force_pafy=True): if not const.args.no_metadata: meta_tags = spotify_tools.generate_metadata(track) else: - if not const.args.no_metadata: + # Let it generate metadata, youtube doesn't know spotify slang + if not const.args.no_metadata or internals.is_spotify(track): meta_tags = spotify_tools.generate_metadata(track) + if force_pafy: content = go_pafy(track, meta_tags) else: @@ -172,6 +174,10 @@ class GenerateYouTubeURL: ) def _best_match(self, videos): + if not videos: + log.error("No videos found on YouTube for a given search") + return None + """ Select the best matching video from a list of videos. """ if const.args.manual: log.info(self.raw_song)