Hook command advanced help

This may be beyond the scope of beets. I’m trying to use a separate python script to pull album art from VGMDB and everything works, but I need to provide a # or link. When automating this through beats, I can’t seem to find any other way to get this to work. Here is the code I’m looking at:

config.yaml

  hooks:
   #not working yet, need to figure out how to input the catalogue number.  want to get this to go soon!
    - event: album_imported
      command: /bin/sh -c 'cd "{album.path}" && python3 /config/scandownloader/vgmdbrip.py $catalognum'
      #command: 'cd "{album.path}" && python3 /config/scandownloader/vgmdbrip.py LZC-2269'

This command works if I put in a number manually, but I’d love to pull it from $catalognum if possible

The $catalognum reference is used when called upon by paths

    default: "[$genre]/%tcp{$album} ($year)(%substitute{$albumtype}) [$catalognum]/$disc_and_track $title"

Resulting in: VISIONS (Feat. Takuma Terashima) ∕ Akane Kumada (2022)(Vocal) [LZC-2269]

I assume it’s because the command is being run somewhat externally it has no reference to any of the actual values in beets. Is there anyway to feed it that somehow?

hook interpolates the whole command, so you should just be able to do:

hook:
  hooks:
    - event: album_imported
      command: /bin/sh -c 'cd "{album.path}" && python3 /config/scandownloader/vgmdbrip.py "{album.catalognum}"'

Wonderful! That worked so elegantly! Thank you :slight_smile: I still have a lot to learn it seems

[EDIT FIXED]: apparently musicbrainz_albumid is actually mb_albumid in beets, but I would never have solved this without your lead in the right direction. Thank you!

Since that seemed so easy; honestly speaking I should have asked about using this tag instead. It will work 100% of the time whereas that one only works if it has a catalog number. As I tag, my files get populated with this tag:

I’d love to use it in the same command, but throwing in album.musicbrainz_albumid didn’t seem to take

1 Like

Yeah beets doesn’t really make it obvious how it maps fields to tags (at least from a user side). You can take a look here to find all of the tag names across all supported formats: mediafile/mediafile.py at 6accdc4c4a7fe4d808b674a97fb5474e12621504 · beetbox/mediafile · GitHub