mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 16:42:42 +01:00
fetchart: add iTunes Store art source; depends on python-itunes
This commit is contained in:
parent
ddf5511624
commit
899eab334b
1 changed files with 28 additions and 0 deletions
|
|
@ -29,6 +29,12 @@ from beets import ui
|
||||||
from beets import util
|
from beets import util
|
||||||
from beets import config
|
from beets import config
|
||||||
|
|
||||||
|
try:
|
||||||
|
import itunes
|
||||||
|
itunes_available = True
|
||||||
|
except ImportError:
|
||||||
|
itunes_available = False
|
||||||
|
|
||||||
IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg']
|
IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg']
|
||||||
CONTENT_TYPES = ('image/jpeg',)
|
CONTENT_TYPES = ('image/jpeg',)
|
||||||
DOWNLOAD_EXTENSION = '.jpg'
|
DOWNLOAD_EXTENSION = '.jpg'
|
||||||
|
|
@ -151,6 +157,24 @@ def google_art(album):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
# Art from the iTunes Store.
|
||||||
|
|
||||||
|
def itunes_art(album):
|
||||||
|
"""Return art URL from iTunes Store given an album title.
|
||||||
|
"""
|
||||||
|
search_string = (album.albumartist + ' ' + album.album).encode('utf-8')
|
||||||
|
try:
|
||||||
|
itunes_album = itunes.search_album(search_string)[0]
|
||||||
|
if itunes_album.get_artwork()['100']:
|
||||||
|
small_url = itunes_album.get_artwork()['100']
|
||||||
|
big_url = small_url.replace('100x100', '1200x1200')
|
||||||
|
return big_url
|
||||||
|
else:
|
||||||
|
log.debug(u'fetchart: album has no artwork in iTunes Store')
|
||||||
|
except IndexError:
|
||||||
|
log.debug(u'fetchart: album not found in iTunes Store')
|
||||||
|
|
||||||
|
|
||||||
# Art from the filesystem.
|
# Art from the filesystem.
|
||||||
|
|
||||||
def filename_priority(filename, cover_names):
|
def filename_priority(filename, cover_names):
|
||||||
|
|
@ -203,6 +227,10 @@ def _source_urls(album):
|
||||||
through this sequence early to avoid the cost of scraping when not
|
through this sequence early to avoid the cost of scraping when not
|
||||||
necessary.
|
necessary.
|
||||||
"""
|
"""
|
||||||
|
# iTunes Store.
|
||||||
|
if itunes_available:
|
||||||
|
yield itunes_art(album)
|
||||||
|
|
||||||
# Cover Art Archive.
|
# Cover Art Archive.
|
||||||
if album.mb_albumid:
|
if album.mb_albumid:
|
||||||
yield caa_art(album.mb_albumid)
|
yield caa_art(album.mb_albumid)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue