mirror of
https://github.com/beetbox/beets.git
synced 2025-12-27 19:12:40 +01:00
"clearart" command for removing embedded album art
This commit is contained in:
parent
73c4bedc41
commit
a0e7c70c64
1 changed files with 17 additions and 2 deletions
|
|
@ -54,7 +54,14 @@ class EmbedCoverArtPlugin(BeetsPlugin):
|
|||
extract(lib, outpath, ui.make_query(args))
|
||||
extract_cmd.func = extract_func
|
||||
|
||||
return [embed_cmd, extract_cmd]
|
||||
# Clear command.
|
||||
clear_cmd = ui.Subcommand('clearart',
|
||||
help='remove images from file metadata')
|
||||
def clear_func(lib, config, opts, args):
|
||||
clear(lib, ui.make_query(args))
|
||||
clear_cmd.func = clear_func
|
||||
|
||||
return [embed_cmd, extract_cmd, clear_cmd]
|
||||
|
||||
# "embedart" command.
|
||||
def embed(lib, imagepath, query):
|
||||
|
|
@ -81,7 +88,6 @@ def extract(lib, outpath, query):
|
|||
return
|
||||
|
||||
# Extract the art.
|
||||
print syspath(item.path)
|
||||
mf = mediafile.MediaFile(syspath(item.path))
|
||||
art = mf.art
|
||||
if not art:
|
||||
|
|
@ -102,6 +108,15 @@ def extract(lib, outpath, query):
|
|||
with open(syspath(outpath), 'wb') as f:
|
||||
f.write(art)
|
||||
|
||||
# "clearart" command.
|
||||
def clear(lib, query):
|
||||
log.info('Clearing album art from items:')
|
||||
for item in lib.items(query=query):
|
||||
log.info(u'%s - %s' % (item.artist, item.title))
|
||||
mf = mediafile.MediaFile(syspath(item.path))
|
||||
mf.art = None
|
||||
mf.save()
|
||||
|
||||
# Automatically embed art into imported albums.
|
||||
@EmbedCoverArtPlugin.listen('album_imported')
|
||||
def album_imported(lib, album):
|
||||
|
|
|
|||
Loading…
Reference in a new issue