mirror of
https://github.com/beetbox/beets.git
synced 2025-12-31 21:12:43 +01:00
Merge pull request #3647 from trolley/topic/coverart-thumbs-2
fetchart: Use Cover Art Archive thumbnails
This commit is contained in:
commit
8deef192e6
2 changed files with 26 additions and 4 deletions
|
|
@ -305,6 +305,7 @@ class RemoteArtSource(ArtSource):
|
|||
class CoverArtArchive(RemoteArtSource):
|
||||
NAME = u"Cover Art Archive"
|
||||
VALID_MATCHING_CRITERIA = ['release', 'releasegroup']
|
||||
VALID_THUMBNAIL_SIZES = [250, 500, 1200]
|
||||
|
||||
if util.SNI_SUPPORTED:
|
||||
URL = 'https://coverartarchive.org/release/{mbid}/front'
|
||||
|
|
@ -317,13 +318,31 @@ class CoverArtArchive(RemoteArtSource):
|
|||
"""Return the Cover Art Archive and Cover Art Archive release group URLs
|
||||
using album MusicBrainz release ID and release group ID.
|
||||
"""
|
||||
release_url = self.URL.format(mbid=album.mb_albumid)
|
||||
release_group_url = self.GROUP_URL.format(mbid=album.mb_releasegroupid)
|
||||
|
||||
# Cover Art Archive API offers pre-resized thumbnails at several sizes.
|
||||
# If the maxwidth config matches one of the already available sizes
|
||||
# fetch it directly intead of fetching the full sized image and
|
||||
# resizing it.
|
||||
size_suffix = None
|
||||
if plugin.maxwidth in self.VALID_THUMBNAIL_SIZES:
|
||||
size_suffix = "-" + str(plugin.maxwidth)
|
||||
|
||||
if 'release' in self.match_by and album.mb_albumid:
|
||||
yield self._candidate(url=self.URL.format(mbid=album.mb_albumid),
|
||||
if size_suffix:
|
||||
release_thumbnail_url = release_url + size_suffix
|
||||
yield self._candidate(url=release_thumbnail_url,
|
||||
match=Candidate.MATCH_EXACT)
|
||||
yield self._candidate(url=release_url,
|
||||
match=Candidate.MATCH_EXACT)
|
||||
if 'releasegroup' in self.match_by and album.mb_releasegroupid:
|
||||
yield self._candidate(
|
||||
url=self.GROUP_URL.format(mbid=album.mb_releasegroupid),
|
||||
match=Candidate.MATCH_FALLBACK)
|
||||
if size_suffix:
|
||||
release_group_thumbnail_url = release_group_url + size_suffix
|
||||
yield self._candidate(url=release_group_thumbnail_url,
|
||||
match=Candidate.MATCH_FALLBACK)
|
||||
yield self._candidate(url=release_group_url,
|
||||
match=Candidate.MATCH_FALLBACK)
|
||||
|
||||
|
||||
class Amazon(RemoteArtSource):
|
||||
|
|
|
|||
|
|
@ -217,6 +217,9 @@ Fixes:
|
|||
results or fetched lyrics
|
||||
:bug:`2805`
|
||||
* Adapt to breaking changes in Python's ``ast`` module in 3.8
|
||||
* :doc:`/plugins/fetchart`: Attempt to fetch pre-resized thumbnails from Cover
|
||||
Art Archive if the ``maxwidth`` option matches one of the sizes supported by
|
||||
the Cover Art Archive API.
|
||||
|
||||
For plugin developers:
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue