From 73c7cc86fe248c9bfca267b0b2f5f4c24fcc5c12 Mon Sep 17 00:00:00 2001 From: David Logie Date: Mon, 22 Nov 2021 20:56:50 +0000 Subject: [PATCH] Add an 'album_removed' event. This works similarly to the existing 'item_removed' event but is called with an `Album` object. --- beets/library.py | 1 + docs/changelog.rst | 2 ++ docs/dev/plugins.rst | 3 +++ 3 files changed, 6 insertions(+) diff --git a/beets/library.py b/beets/library.py index d35a7fae6..4fc70987a 100644 --- a/beets/library.py +++ b/beets/library.py @@ -878,6 +878,7 @@ class Item(LibModel): album = self.get_album() if album and not album.items(): album.remove(delete, False) + plugins.send('album_removed', album=album) # Send a 'item_removed' signal to plugins plugins.send('item_removed', item=self) diff --git a/docs/changelog.rst b/docs/changelog.rst index 9ed497d3b..34fc8338e 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -51,6 +51,8 @@ Other new things: yes`` in your configuration to enable. * :doc:`/plugins/fetchart`: A new option to change cover art format. Useful for DAPs that do not support some image formats. +* New plugin event: ``album_removed``. Called when an album is removed from the + library (even when its file is not deleted from disk). For plugin developers: diff --git a/docs/dev/plugins.rst b/docs/dev/plugins.rst index b32955b61..3956aa760 100644 --- a/docs/dev/plugins.rst +++ b/docs/dev/plugins.rst @@ -143,6 +143,9 @@ The events currently available are: command finishes adding an album to the library. Parameters: ``lib``, ``album`` +* `album_removed`: called with an ``Album`` object every time an album is + removed from the library (even when its file is not deleted from disk). + * `item_copied`: called with an ``Item`` object whenever its file is copied. Parameters: ``item``, ``source`` path, ``destination`` path