mirror of
https://github.com/beetbox/beets.git
synced 2025-12-30 12:32:33 +01:00
Changed the interface of extractart to make it easier to understand what it does.
This commit is contained in:
parent
2631d88b39
commit
07cea16492
3 changed files with 29 additions and 19 deletions
|
|
@ -88,22 +88,30 @@ class EmbedCoverArtPlugin(BeetsPlugin):
|
|||
help='extract an image from file metadata')
|
||||
extract_cmd.parser.add_option('-o', dest='outpath',
|
||||
help='image output file')
|
||||
extract_cmd.parser.add_option('-a', dest='albums', action='store_true',
|
||||
help='extract the art of all matching '
|
||||
'albums')
|
||||
extract_cmd.parser.add_option('-n', dest='filename',
|
||||
help='image filename to create for all '
|
||||
'matched albums')
|
||||
extract_cmd.parser.add_option('-a', dest='associate',
|
||||
action='store_true',
|
||||
help='associate the extracted images '
|
||||
'with the album')
|
||||
|
||||
def extract_func(lib, opts, args):
|
||||
outpath = opts.outpath or config['art_filename'].get()
|
||||
if opts.albums:
|
||||
if opts.outpath and '/' in opts.outpath.replace('\\', '/'):
|
||||
self._log.error(u"When using -a, only specify a filename "
|
||||
u"instead of a full path for -o")
|
||||
if opts.filename:
|
||||
filename = opts.filename
|
||||
if os.path.dirname(filename) != '':
|
||||
self._log.error(u"Only specify a name rather a path for "
|
||||
u"-n")
|
||||
return
|
||||
for album in lib.albums(decargs(args)):
|
||||
artpath = normpath(os.path.join(album.path, outpath))
|
||||
self.extract_first(artpath, album.items())
|
||||
artpath = normpath(os.path.join(album.path, filename))
|
||||
artpath = self.extract_first(artpath, album.items())
|
||||
if artpath and opts.associate:
|
||||
album.set_art(artpath)
|
||||
|
||||
else:
|
||||
outpath = normpath(outpath)
|
||||
outpath = normpath(opts.outpath
|
||||
or config['art_filename'].get())
|
||||
self.extract_first(outpath, lib.items(decargs(args)))
|
||||
extract_cmd.func = extract_func
|
||||
|
||||
|
|
@ -270,8 +278,9 @@ class EmbedCoverArtPlugin(BeetsPlugin):
|
|||
|
||||
def extract_first(self, outpath, items):
|
||||
for item in items:
|
||||
if self.extract(outpath, item):
|
||||
return outpath
|
||||
real_path = self.extract(outpath, item)
|
||||
if real_path:
|
||||
return real_path
|
||||
|
||||
# 'clearart' command.
|
||||
def clear(self, lib, query):
|
||||
|
|
|
|||
|
|
@ -26,8 +26,9 @@ Features:
|
|||
by default. :bug:`1246`
|
||||
* :doc:`/plugins/fetchart`: Names of extracted image art is taken from the
|
||||
``art_filename`` configuration option. :bug:`1258`
|
||||
* :doc:`/plugins/fetchart`: New option ``-a`` to extract the cover art of all
|
||||
matched albums into its directory. :bug:`1261`
|
||||
* :doc:`/plugins/fetchart`: New option ``-n`` to extract the cover art of all
|
||||
matched albums into its directory. It's also possible to automatically
|
||||
associate them with the album when adding ``-a`` :bug:`1261`
|
||||
* :doc:`/plugins/fetchart`: There's a new Wikipedia image source that uses
|
||||
DBpedia to find albums. Thanks to Tom Jaspers. :bug:`1194`
|
||||
|
||||
|
|
|
|||
|
|
@ -84,11 +84,11 @@ embedded album art:
|
|||
``art_filename`` configuration option. It defaults to ``cover`` if it's not
|
||||
specified via ``-o`` nor the config.
|
||||
|
||||
* ``beet extractart -a [-o FILE] QUERY``: extracts the images for all albums
|
||||
* ``beet extractart [-a] [-n FILE] QUERY``: extracts the images for all albums
|
||||
matching the query. The images are placed inside the album folder. The
|
||||
destination filename is taken either from the ``-o`` option or the
|
||||
``art_filename`` configuration option. It defaults to ``cover`` if it's not
|
||||
specified.
|
||||
destination filename is taken either from the ``-n`` option. Using ``-a``,
|
||||
the extracted image files are automatically associated with the corresponding
|
||||
album.
|
||||
|
||||
* ``beet clearart QUERY``: removes all embedded images from all items matching
|
||||
the query. (Use with caution!)
|
||||
|
|
|
|||
Loading…
Reference in a new issue