Skip to content

Commit

Permalink
Fix Issue #1038 (#1043)
Browse files Browse the repository at this point in the history
Author: @s1as3r 

* Fix Issue #1038

Fixes [Issue #1038](#1038)

- When searching for a song, spotdl gathers all the results that the youtube music api provides. 
- If one of the songs in the results is not available in a country, 'playNavigationEndpoint' key would not be present in it's result, hence this error.

* Update provider.py

Made Changes as suggested by @tytydraco

* Update provider.py

- Used `.get()` method instead of a try-except block.
  • Loading branch information
s1as3r authored Jan 1, 2021
1 parent b7a517b commit 162d7ce
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions spotdl/search/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,16 @@ def __query_and_simplify(searchTerm: str, apiKey: str = ytmApiKey) -> List[dict]


# Add the linkBlock

linkBlock = contents['musicResponsiveListItemRenderer'] \
['overlay'] \
['musicItemThumbnailOverlayRenderer'] \
['content'] \
['musicPlayButtonRenderer'] \
['playNavigationEndpoint']
['overlay'] \
['musicItemThumbnailOverlayRenderer'] \
['content'] \
['musicPlayButtonRenderer'].get('playNavigationEndpoint')

if linkBlock is None:
continue

#! detailsBlock is always a list, so we just append the linkBlock to it
#! insted of carrying along all the other junk from 'musicResponsiveListItemRenderer'
result.append(linkBlock)
Expand Down

0 comments on commit 162d7ce

Please sign in to comment.