diff --git a/beets/library.py b/beets/library.py index 33aa314bf..5764d4bb5 100644 --- a/beets/library.py +++ b/beets/library.py @@ -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. diff --git a/beetsplug/embedart.py b/beetsplug/embedart.py index e84b39737..07dfe066d 100644 --- a/beetsplug/embedart.py +++ b/beetsplug/embedart.py @@ -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) diff --git a/beetsplug/thumbnails.py b/beetsplug/thumbnails.py index 5ba6da57f..5ab1656b2 100644 --- a/beetsplug/thumbnails.py +++ b/beetsplug/thumbnails.py @@ -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():