mirror of
https://github.com/beetbox/beets.git
synced 2026-01-24 17:12:07 +01:00
Seperated some code out from extract() into get_art(item). Cleaner and quicker way to check for embedded art.
This commit is contained in:
parent
7f37514bb9
commit
ca431b0bf8
1 changed files with 14 additions and 10 deletions
|
|
@ -118,8 +118,7 @@ def embed_item(item, imagepath, maxwidth=None, itempath=None,
|
|||
log.warn(u'Image not similar; skipping.')
|
||||
return
|
||||
if ifempty:
|
||||
with NamedTemporaryFile(delete=True) as f:
|
||||
art = extract(f.name, item)
|
||||
art = get_art(item)
|
||||
if not art:
|
||||
pass
|
||||
else:
|
||||
|
|
@ -213,13 +212,7 @@ def _mediafile_image(image_path, maxwidth=None):
|
|||
return mediafile.Image(data, type=mediafile.ImageType.front)
|
||||
|
||||
|
||||
# 'extractart' command.
|
||||
|
||||
def extract(outpath, item):
|
||||
if not item:
|
||||
log.error(u'No item matches query.')
|
||||
return
|
||||
|
||||
def get_art(item):
|
||||
# Extract the art.
|
||||
try:
|
||||
mf = mediafile.MediaFile(syspath(item.path))
|
||||
|
|
@ -229,7 +222,18 @@ def extract(outpath, item):
|
|||
))
|
||||
return
|
||||
|
||||
art = mf.art
|
||||
return mf.art
|
||||
|
||||
# 'extractart' command.
|
||||
|
||||
|
||||
def extract(outpath, item):
|
||||
if not item:
|
||||
log.error(u'No item matches query.')
|
||||
return
|
||||
|
||||
art = get_art(item)
|
||||
|
||||
if not art:
|
||||
log.error(u'No album art present in {0} - {1}.'
|
||||
.format(item.artist, item.title))
|
||||
|
|
|
|||
Loading…
Reference in a new issue