Plugin development: get file from track

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,

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):

2 Likes

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

Also see discussion over at Get files from objects

See my hack documented at Get files from objects - #8 by MetaTunes

1 Like