mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
Add send_art event for embedart and thumbnails
Album.set_art() sends a 'art_sent' event, with the album as a parameter. embedart and thumbnails listen to that event, instead of listening to 'album imported'. Consequences: - 'embedart' and 'thumbnails' don't have to be after 'fetchart' on the plugins config line. - embedart and thumbnails work event when a "beets fetchart" command is issued. - if another plugin ever set art then embedart and thumbnails will "just work" with it.
This commit is contained in:
parent
0a37c4652e
commit
a72ae5991f
3 changed files with 9 additions and 8 deletions
|
|
@ -960,6 +960,8 @@ class Album(LibModel):
|
|||
"""Sets the album's cover art to the image at the given path.
|
||||
The image is copied (or moved) into place, replacing any
|
||||
existing art.
|
||||
|
||||
Sends an 'art_set' event with `self` as the sole argument.
|
||||
"""
|
||||
path = bytestring_path(path)
|
||||
oldart = self.artpath
|
||||
|
|
@ -983,6 +985,8 @@ class Album(LibModel):
|
|||
util.move(path, artdest)
|
||||
self.artpath = artdest
|
||||
|
||||
plugins.send('art_set', album=self)
|
||||
|
||||
def store(self):
|
||||
"""Update the database with the album information. The album's
|
||||
tracks are also updated.
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class EmbedCoverArtPlugin(BeetsPlugin):
|
|||
self._log.warning(u"ImageMagick 6.8.7 or higher not installed; "
|
||||
u"'compare_threshold' option ignored")
|
||||
|
||||
self.register_listener('album_imported', self.album_imported)
|
||||
self.register_listener('art_set', self.process_album)
|
||||
|
||||
def commands(self):
|
||||
# Embed command.
|
||||
|
|
@ -106,10 +106,10 @@ class EmbedCoverArtPlugin(BeetsPlugin):
|
|||
|
||||
return [embed_cmd, extract_cmd, clear_cmd]
|
||||
|
||||
def album_imported(self, lib, album):
|
||||
"""Automatically embed art into imported albums.
|
||||
def process_album(self, album):
|
||||
"""Automatically embed art after art has been set
|
||||
"""
|
||||
if album.artpath and self.config['auto']:
|
||||
if self.config['auto']:
|
||||
max_width = self.config['maxwidth'].get(int)
|
||||
self.embed_album(album, max_width, True)
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class ThumbnailsPlugin(BeetsPlugin):
|
|||
|
||||
self.write_metadata = None
|
||||
if self.config['auto'] and self._check_local_ok():
|
||||
self.register_listener('album_imported', self.imported)
|
||||
self.register_listener('art_set', self.process_album)
|
||||
|
||||
def commands(self):
|
||||
thumbnails_command = Subcommand("thumbnails",
|
||||
|
|
@ -68,9 +68,6 @@ class ThumbnailsPlugin(BeetsPlugin):
|
|||
|
||||
return [thumbnails_command]
|
||||
|
||||
def imported(self, lib, album):
|
||||
self.process_album(album)
|
||||
|
||||
def process_query(self, lib, opts, args):
|
||||
self.config.set_args(opts)
|
||||
if self._check_local_ok():
|
||||
|
|
|
|||
Loading…
Reference in a new issue