From 6ed430d730f99f5e34c6f83b1d7fbea10228ca9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Inge=20Lea=20Bj=C3=B8rnsen?= Date: Tue, 14 Jan 2014 21:53:12 +0100 Subject: [PATCH] Send a plugin event when a file is copied. I use this event in a plugin that needs to know which file outside the library an item was copied from during import. --- beets/library.py | 2 ++ docs/dev/plugins.rst | 3 +++ 2 files changed, 5 insertions(+) diff --git a/beets/library.py b/beets/library.py index b79e5d013..750d3fe83 100644 --- a/beets/library.py +++ b/beets/library.py @@ -350,6 +350,8 @@ class Item(LibModel): dest = util.unique_path(dest) if copy: util.copy(self.path, dest) + plugins.send("item_copied", item=self, source=self.path, + destination=dest) else: util.move(self.path, dest) plugins.send("item_moved", item=self, source=self.path, diff --git a/docs/dev/plugins.rst b/docs/dev/plugins.rst index e18fc1584..5645ca740 100644 --- a/docs/dev/plugins.rst +++ b/docs/dev/plugins.rst @@ -124,6 +124,9 @@ currently available are: command finishes adding an album to the library. Parameters: ``lib``, ``album`` +* *item_copied*: called with an ``Item`` object whenever its file is copied. + Parameters: ``item``, ``source`` path, ``destination`` path + * *item_imported*: called with an ``Item`` object every time the importer adds a singleton to the library (not called for full-album imports). Parameters: ``lib``, ``item``