mirror of
https://github.com/beetbox/beets.git
synced 2026-02-24 16:23:04 +01:00
Error handling
This commit is contained in:
parent
acd604f102
commit
c00cdd3cc7
1 changed files with 6 additions and 3 deletions
|
|
@ -16,6 +16,7 @@
|
|||
"""
|
||||
|
||||
import collections
|
||||
import re
|
||||
import time
|
||||
|
||||
import requests
|
||||
|
|
@ -72,18 +73,20 @@ class DeezerPlugin(MetadataSourcePlugin, BeetsPlugin):
|
|||
:rtype: beets.autotag.hooks.AlbumInfo or None
|
||||
"""
|
||||
deezer_id = self._get_id('album', album_id, self.id_regex)
|
||||
if deezer_id is None or not self.id_regex.match(deezer_id):
|
||||
self._log.debug("Invalid Deezer ID found: %s", deezer_id)
|
||||
if deezer_id is None:
|
||||
return None
|
||||
|
||||
album_data = requests.get(self.album_url + deezer_id).json()
|
||||
if 'error' in album_data:
|
||||
self._log.debug(f"Error fetching album {album_id}: "
|
||||
f"{album_data['error']['message']}")
|
||||
return None
|
||||
contributors = album_data.get('contributors')
|
||||
if contributors is not None:
|
||||
artist, artist_id = self.get_artist(contributors)
|
||||
else:
|
||||
artist, artist_id = None, None
|
||||
|
||||
|
||||
release_date = album_data['release_date']
|
||||
date_parts = [int(part) for part in release_date.split('-')]
|
||||
num_date_parts = len(date_parts)
|
||||
|
|
|
|||
Loading…
Reference in a new issue