I want to write a hook that can “clean up” imported albums after they’re successfully imported (for various reasons, I don’t want to just let beet move the files; I’d rather beet do a copy and then let me clean up the old files myself).
However, I can’t seem to find a hook event that fits this fairly basic use-case.
-
The
importevent seemed like the most promising option, since the documentation says:called after a
beet importcommand finishes (thelibkeyword argument is a Library object;pathsis a list of paths (strings) that were importedHowever, this seems to be misleading, since the event fires after every import command (even those that didn’t “finish”) and
pathscontains every path that was passed toimport, regardless of whether it was actually imported or not (if it was skipped, for instance). So with no clear way for my script to distinguish between actually-imported albums and non-imported ones, this event doesn’t work. -
album_importedalso seemed promising, since it does correctly fire only after an album is actually imported, but unfortunately there’s nothing in theliboralbumparameters that tells me which path was actually being imported, so the hook has no way to clean up just those files. -
import_task_applyalso seemed relevant but it doesn’t seem to fire at all, my test command wasn’t firing after an import whether successful or not; and anyway even if it had, it wasn’t clear whether any of its parameters would include the path being imported anyway.
Short of writing a full plugin with a new pipeline stage, is there any way for hook to accomplish what I’m trying to do here? And if not, would it be possible to add some sort of new parameter to the import callback that itemizes whether each item in paths was actually imported or not? That seems like a pretty generically useful thing to have.
Thanks!