Variable path for singletons based on band presence in album folder


#1

Hi, I have two music folders:

  • Albums
  • Non-Album

I would like to have each band to be just once in one of these folders.
Is it possible to have the importer in singleton mode check if the band is already present in albums, and if so, change the path for that music file?

In code (for config.yaml or elsewhere) should be something like:
#In singleton mode:
#If $artist IN Muziek_Album/$albumartist THEN singleton: Muziek_Album/$artist/#Non-album/$title
paths:
default: Muziek_Album/$albumartist/$album%aunique{}/$track $title
singleton: Muziek_Non-Album/$artist/$title
comp: Muziek_Album/#Compilations/$album%aunique{}/$track $title

Then f.e. I would have:
AC_DC/#Non-album
AC_DC/Powerage
AC_DC/Black Ice


#2

Something like this will require a bit of hackery—checking the filesystem to determine a path won’t be accomplishable without it. Specifically, you will need to either create a custom plugin or use the inline plugin, which lets you use Python code to define new fields. In either case, you can import os.path and use that to check whether a given directory exists, or you can issue queries back to the beets database to see if there are albums with a given artist. To do the latter, the code will look something like lib.albums(dbcore.query.MatchQuery(‘albumartist’, some_artist)).


#3

Adrian, thanks for your response, I will try to get started with your information.
I’m quite new to Linux but I like programming so i’m happy to spend some time on it.

If I find the solution I will post it here!