From b6290e289508fedb709de0a8f3e25d87724997b5 Mon Sep 17 00:00:00 2001 From: "nath@home" Date: Sat, 8 Aug 2015 21:44:50 +0200 Subject: [PATCH 1/4] clearart-notify: Send write events when clearing art For example, this led beets-check to not recompute hashes when doing beet clearart [query]. Further operations on the file(s) would then trigger beets-check to issue integrity warnings. --- beets/art.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/beets/art.py b/beets/art.py index 8b77899fbc..54659efb25 100644 --- a/beets/art.py +++ b/beets/art.py @@ -26,6 +26,7 @@ from beets.util.artresizer import ArtResizer from beets import mediafile from beets import config +from beets import plugins def mediafile_image(image_path, maxwidth=None): @@ -205,3 +206,4 @@ def clear(log, lib, query): else: del mf.art mf.save() + plugins.send('after_write', item=item, path=item.path) From b53798aaf95090f638321088fc8091da6e49a895 Mon Sep 17 00:00:00 2001 From: "nath@home" Date: Sun, 9 Aug 2015 00:18:23 +0200 Subject: [PATCH 2/4] clearart-notify: Use item.try_write() to clear art This method already groups reading the config, managing file I/O and exceptions, as well as sending events to the plugins, so it's really easier and cleaner to do it that way. Note that passing 'images':None as tags to update correctly triggers beets to delete the images tag altogether. --- beets/art.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/beets/art.py b/beets/art.py index 54659efb25..65b171e8ec 100644 --- a/beets/art.py +++ b/beets/art.py @@ -25,8 +25,6 @@ from beets.util import displayable_path, syspath from beets.util.artresizer import ArtResizer from beets import mediafile -from beets import config -from beets import plugins def mediafile_image(image_path, maxwidth=None): @@ -192,18 +190,8 @@ def extract_first(log, outpath, items): def clear(log, lib, query): - id3v23 = config['id3v23'].get(bool) - items = lib.items(query) log.info(u'Clearing album art from {0} items', len(items)) for item in items: log.debug(u'Clearing art for {0}', item) - try: - mf = mediafile.MediaFile(syspath(item.path), id3v23) - except mediafile.UnreadableFileError as exc: - log.warning(u'Could not read file {0}: {1}', - displayable_path(item.path), exc) - else: - del mf.art - mf.save() - plugins.send('after_write', item=item, path=item.path) + item.try_write(path=item.path, tags={'images': None}) From 8773d958c1b591773e3328b3bcc456442a48e794 Mon Sep 17 00:00:00 2001 From: "nath@home" Date: Mon, 10 Aug 2015 01:11:47 +0200 Subject: [PATCH 3/4] clearart-notify: Use default arguments when clearing art --- beets/art.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beets/art.py b/beets/art.py index 65b171e8ec..79bdfefe42 100644 --- a/beets/art.py +++ b/beets/art.py @@ -194,4 +194,4 @@ def clear(log, lib, query): log.info(u'Clearing album art from {0} items', len(items)) for item in items: log.debug(u'Clearing art for {0}', item) - item.try_write(path=item.path, tags={'images': None}) + item.try_write(tags={'images': None}) From 8bf60ee8df074a1b65063f9c6c7bfa52fee2c9c1 Mon Sep 17 00:00:00 2001 From: "nath@home" Date: Sat, 22 Aug 2015 23:49:04 +0200 Subject: [PATCH 4/4] clearart-notify: Added changelog entry --- docs/changelog.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 3003775798..b83168f327 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -17,6 +17,9 @@ Fixes: * :doc:`/plugins/lastgenre`: Fix a bug that prevented tag popularity from being considered. Thanks to :user:`svoos`. :bug:`1559` +* Fixed a bug where plugins wouldn't be notified of the deletion of an item's + art, for example with the ``clearart`` command from the + :doc:`/plugins/embedart`. Thanks to :user:`nathdwek`. :bug:`1565` 1.3.14 (August 2, 2015)