Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish Version 3.4.0 #1204

Merged
merged 12 commits into from
Mar 16, 2021
Prev Previous commit
Next Next commit
skip results without videoId (#1202)
Authored by @xnetcat 

* skip results  without videoId
* Update provider.py
* Update provider.py
* flake8
  • Loading branch information
xnetcat committed Mar 14, 2021
commit 5478228e57739905581044eb36567aeee64b1e32
9 changes: 8 additions & 1 deletion spotdl/search/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ def _parse_duration(duration: str) -> float:

def _map_result_to_song_data(result: dict) -> dict:
artists = ", ".join(map(lambda a: a['name'], result['artists']))
video_id = result['videoId']
video_id = result.get('videoId', None)
if video_id is None:
return {}
song_data = {
'name': result['title'],
'type': result['resultType'],
Expand Down Expand Up @@ -152,6 +154,11 @@ def search_and_order_ytm_results(songName: str, songArtists: List[str],
linksWithMatchValue = {}

for result in results:
# ! skip results without videoId, this happens if you are country restricted or
# ! video is unavailabe
if result == {}:
continue

# ! If there are no common words b/w the spotify and YouTube Music name, the song
# ! is a wrong match (Like Ruelle - Madness being matched to Ruelle - Monster, it
# ! happens without this conditional)
Expand Down