mirror of
https://github.com/beetbox/beets.git
synced 2025-12-10 02:22:25 +01:00
Merge pull request #4972 from henges/henges/discogs-fetchart
discogs: Populate `cover_art_url` attribute
This commit is contained in:
commit
a2d6819276
3 changed files with 16 additions and 1 deletions
|
|
@ -425,6 +425,8 @@ class DiscogsPlugin(BeetsPlugin):
|
|||
catalogno = result.data["labels"][0].get("catno")
|
||||
labelid = result.data["labels"][0].get("id")
|
||||
|
||||
cover_art_url = self.select_cover_art(result)
|
||||
|
||||
# Additional cleanups (various artists name, catalog number, media).
|
||||
if va:
|
||||
artist = config["va_name"].as_str()
|
||||
|
|
@ -474,8 +476,19 @@ class DiscogsPlugin(BeetsPlugin):
|
|||
discogs_albumid=discogs_albumid,
|
||||
discogs_labelid=labelid,
|
||||
discogs_artistid=artist_id,
|
||||
cover_art_url=cover_art_url,
|
||||
)
|
||||
|
||||
def select_cover_art(self, result):
|
||||
"""Returns the best candidate image, if any, from a Discogs `Release` object."""
|
||||
if result.data.get("images") and len(result.data.get("images")) > 0:
|
||||
# The first image in this list appears to be the one displayed first
|
||||
# on the release page - even if it is not flagged as `type: "primary"` - and
|
||||
# so it is the best candidate for the cover art.
|
||||
return result.data.get("images")[0].get("uri")
|
||||
|
||||
return None
|
||||
|
||||
def format(self, classification):
|
||||
if classification:
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -1098,7 +1098,7 @@ class CoverArtUrl(RemoteArtSource):
|
|||
image_url = None
|
||||
try:
|
||||
# look for cover_art_url on album or first track
|
||||
if album.cover_art_url:
|
||||
if album.get("cover_art_url"):
|
||||
image_url = album.cover_art_url
|
||||
else:
|
||||
image_url = album.items().get().cover_art_url
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ Major new features:
|
|||
|
||||
New features:
|
||||
|
||||
* :doc:`plugins/discogs`: supply a value for the `cover_art_url` attribute, for use by `fetchart`.
|
||||
:bug:`429`
|
||||
* :ref:`update-cmd`: added ```-e``` flag for excluding fields from being updated.
|
||||
* :doc:`/plugins/deezer`: Import rank and other attributes from Deezer during import and add a function to update the rank of existing items.
|
||||
:bug:`4841`
|
||||
|
|
|
|||
Loading…
Reference in a new issue