fix test, document Spotify ID

This commit is contained in:
Rahul Ahuja 2019-01-20 02:20:10 -08:00
parent 9a30000b56
commit b95eaa8ffe
2 changed files with 6 additions and 4 deletions

View file

@ -24,7 +24,6 @@ class SpotifyPlugin(BeetsPlugin):
album_url = 'https://api.spotify.com/v1/albums/'
track_url = 'https://api.spotify.com/v1/tracks/'
playlist_partial = 'spotify:trackset:Playlist:'
id_regex = r'(^|open\.spotify\.com/{}/)([0-9A-Za-z]{{22}})'
def __init__(self):
super(SpotifyPlugin, self).__init__()
@ -126,8 +125,11 @@ class SpotifyPlugin(BeetsPlugin):
:return: Spotify ID
:rtype: str
"""
# Spotify IDs consist of 22 alphanumeric characters
# (zero-left-padded base62 representation of randomly generated UUID4)
id_regex = r'(^|open\.spotify\.com/{}/)([0-9A-Za-z]{{22}})'
self._log.debug(u'Searching for {} {}', url_type, id_)
match = re.search(self.id_regex.format(url_type), id_)
match = re.search(id_regex.format(url_type), id_)
return match.group(2) if match else None
def album_for_id(self, album_id):

View file

@ -71,7 +71,7 @@ class SpotifyPluginTest(_common.TestCase, TestHelper):
responses.add(
responses.GET,
spotify.SpotifyPlugin.base_url,
spotify.SpotifyPlugin.search_url,
body=response_body,
status=200,
content_type='application/json',
@ -103,7 +103,7 @@ class SpotifyPluginTest(_common.TestCase, TestHelper):
responses.add(
responses.GET,
spotify.SpotifyPlugin.base_url,
spotify.SpotifyPlugin.search_url,
body=response_body,
status=200,
content_type='application/json',