Skip to content

Commit

Permalink
Spotify Ext: Fix regex returning None on certain URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
EvieePy committed Mar 13, 2022
1 parent 8c31198 commit 3acb9b8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions wavelink/ext/spotify/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@


GRANTURL = 'https://accounts.spotify.com/api/token?grant_type=client_credentials'
URLREGEX = re.compile(r'https://open\.spotify\.com/(?P<entity>.+)/(?P<identifier>.+)\?')
URLREGEX = re.compile(r'(https?://open.)?(spotify)(.com/|:)'
r'(?P<type>album|playlist|track|artist)([/:])'
r'(?P<id>[a-zA-Z0-9]+)(\?si=[a-zA-Z0-9]+)?(&dl_branch=[0-9]+)?')
BASEURL = 'https://api.spotify.com/v1/{entity}s/{identifier}'

ST = TypeVar("ST", bound="SearchableTrack")
Expand Down Expand Up @@ -83,11 +85,11 @@ def decode_url(url: str) -> Optional[dict]:
match = URLREGEX.match(url)
if match:
try:
type_ = SpotifySearchType[match['entity']]
type_ = SpotifySearchType[match['type']]
except KeyError:
type_ = SpotifySearchType.unusable

return {'type': type_, 'id': match['identifier']}
return {'type': type_, 'id': match['id']}

return None

Expand Down

0 comments on commit 3acb9b8

Please sign in to comment.