Calling external command after save action

Hi!

Is it possible to make Picard automatically call an external command after saving files? I would be very happy that “collectiongain” is executed at that time on my collection (see https://github.com/cacack/rgain), possibly via a plugin? Can the plugin system allow to hook after the save file action?

Thanks!

1 Like

Not sure about the general case, but for this specific case you should be able to use the Replaygain plug-in.

1 Like

Actually rgain does a much better job than Picard ReplayGain plugin (which use the unmaintained mp3gain tool under the hood)…

If you say so. Regardless, the general case is interesting, but I have no idea. Maybe @Sophist would know?

I took a quick look at the ReplayGain plugin code. The way it works is to add ReplayGain to Album and File context (right-click) menus so that you can manually run the plugin on a file. For obvious reasons, you would not want to run replaygain on files automatically (at load or save) unless you could reliably determine that the replay gain has not already been calculated. Similarly you would not want to run replaygain on every file on save, unless it checked to see if it was needed.

Picard does not currently support replaygain tags (e.g. ID3v23 RVAD, id3v24 RVA2), and I don’t think it is that easy to patch Picard from a plugin to add this support - adding this support to Picard is on my To-Do list when I get the time (which is not soon - as I have other open-source developments I am working on at present).

However, once Picard supports the tags, it should be possible to write a plugin which checks the tags on file loading and calculates the replaygain for those files which don’t have the tags.

It should be noted that (according to HydrogenAudio and Wikipedia) mp3gain does not set the RVAD/RVA2 tags, but instead adjusts the volume of each MP3 frame. It apparently stores the original information in a tag so it can be reversed, but I haven’t researched what this tag is and whether this could be used to determine whether you need to run replaygain. I haven’t looked into what the replaygain utilities for other formats do.

It should also be noted that rgain does not support id3vRVAD, only id3v24 RVA2. Again, it should be possible to hack the rgain code to include it in the plugin rather than run it as an external command.

1 Like

Sorry to dig up an old topic, but im curious about this as well. In the General case. I’d like to kick off a bat file after saves are completed. how would i go about doing that?

Vote for https://tickets.metabrainz.org/browse/PICARD-1130

With this patch, it is possible to write a plugin that actually do whatever you want after a file was saved.

def test_file_post_save(file_object, new_filename):
    print("%r %r" % (file_object, new_filename))

register_file_post_save_processor(test_file_post_save)

Output from code example, after album was saved:

<File '01 Alta Magia.flac'> '/home/zas/Musique/Rumbo Tumba/Madera Sur/01 Alta Magia.flac'
<File '02 La Línea del Río.flac'> '/home/zas/Musique/Rumbo Tumba/Madera Sur/02 La Línea del Río.flac'
<File '03 San Anita.flac'> '/home/zas/Musique/Rumbo Tumba/Madera Sur/03 San Anita.flac'
<File '04 La Calor.flac'> '/home/zas/Musique/Rumbo Tumba/Madera Sur/04 La Calor.flac'
<File '05 Marti.flac'> '/home/zas/Musique/Rumbo Tumba/Madera Sur/05 Marti.flac'
<File '06 Revuelta.flac'> '/home/zas/Musique/Rumbo Tumba/Madera Sur/06 Revuelta.flac'
<File '07 Coyugua.flac'> '/home/zas/Musique/Rumbo Tumba/Madera Sur/07 Coyugua.flac'
<File '08 El Vuelo.flac'> '/home/zas/Musique/Rumbo Tumba/Madera Sur/08 El Vuelo.flac'
4 Likes