Plugin development: get file from track

track
picardplugins
metadata
api
Tags: #<Tag:0x00007f24c805d518> #<Tag:0x00007f24c805d298> #<Tag:0x00007f24c805d0e0> #<Tag:0x00007f24c805cdc0>

#1

I’m trying to learn the Picard plugin API by writing a plugin that reads a file in the same directory as an mp3 file, reads data from it, and adds that to the track’s metadata.

I’m stuck on the first step: “find a file in the same directory as the MP3 file being tagged”. I can’t seem to get the path to the file being tagged. If I had that, I could just dirname it and look for my data file.

It looks as though I need to

def track_local_file(tagger, metadata, release, track):
...
register_track_metadata_processor(track_local_file)

But once track_local_file is called, none of the arguments seem to have a file or directory path.
Any tips? Thanks,


Get files from objects
Get files from objects
#2

The best suggestion is to take a plugin that is already doing something like you want and see what that does. See the source in github and look at bpm, moodbars, replaygain etc.

What you probably need to do is call:
register_file_action(xxxx)
This should then call the following with the file you are processing:
def _add_file_to_queue(self, file):


#3

Thanks! I was wondering whether I might need to use some other plugin type, but I didn’t know which one.


#4

Also see discussion over at Get files from objects