Handle empty deezer_id upfront
@@ -54,7 +54,11 @@ class DeezerPlugin(BeetsPlugin):
id_regex = r'(^|deezer\.com/([a-z]*/)?{}/)([0-9]*)'
self._log.debug(u'Searching for {} {}', url_type, id_)
match = re.search(id_regex.format(url_type), str(id_))
- return match.group(3) if match else None
+ if match:
+ deezer_id = match.group(3)
+ if deezer_id:
+ return deezer_id
+ return None
def album_for_id(self, album_id):
"""Fetch an album by its Deezer ID or URL and return an
@@ -66,7 +70,7 @@ class DeezerPlugin(BeetsPlugin):
:rtype: beets.autotag.hooks.AlbumInfo or None
"""
deezer_id = self._get_deezer_id('album', album_id)
- if not deezer_id:
+ if deezer_id is None:
return None
album_data = requests.get(self.album_url + deezer_id).json()
