From 155a5cd6d102f9dc4bfa15ee93ad43b17f5b1b18 Mon Sep 17 00:00:00 2001 From: Maritsu <66056347+Maritsu@users.noreply.github.com> Date: Thu, 11 Jul 2024 19:16:16 +0200 Subject: [PATCH] try to search for videos if no song is found instead of skipping --- spotify_dl/youtube.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/spotify_dl/youtube.py b/spotify_dl/youtube.py index 5eeba24..f54c383 100644 --- a/spotify_dl/youtube.py +++ b/spotify_dl/youtube.py @@ -48,8 +48,11 @@ def dump_json(songs): # Reduce results to array of titles and video IDs search_results = ym.search(query, filter="songs") if len(search_results) == 0: - log.error(f"No results found for {query}, skipping.") - continue + log.warning("No song results found for %s, retrying.", query) + search_results = ym.search(query, filter="videos") + if len(search_results) == 0: + log.error("No search results found for %s, skipping.", query) + continue result_titles, result_ids = zip(*map( lambda d: (f"{d['artists'][0]['name']} - {d['title']}".replace(":", "").replace('"', ""), d["videoId"]), search_results @@ -220,8 +223,11 @@ def find_and_download_songs(kwargs): # Reduce search results to array of titles and video IDs search_results = ym.search(query, filter="songs") if len(search_results) == 0: - log.error(f"No results found for {query}, skipping.") - continue + log.warning("No song results found for %s, retrying.", query) + search_results = ym.search(query, filter="videos") + if len(search_results) == 0: + log.error("No search results found for %s, skipping.", query) + continue result_titles, result_ids = zip(*map( lambda d: (f"{d['artists'][0]['name']} - {d['title']}".replace(":", "").replace('"', ""), d["videoId"]), search_results