{ pkgs, lib, ... }: let inherit (lib) concatStringsSep listToAttrs; plugins = [ "convert" "chroma" "inline" "fish" "fetchart" "lastgenre" "scrub" "duplicates" "info" "missing" "unimported" "badfiles" ]; in { config = { programs.beets = { package = pkgs.beets.override { pluginOverrides = listToAttrs ( map (name: { value.enable = true; inherit name; }) plugins ); }; settings = { plugins = concatStringsSep " " plugins; per_disc_numbering = "yes"; asciify_paths = true; convert = { auto = "yes"; format = "flac"; never_convert_lossy_files = "yes"; }; fetchart = { auto = true; cover_format = "jpg"; maxwidth = 500; minwidth = 500; enforce_ratio = true; high_resolution = true; }; duplicates = { count = true; }; lastgenre = { auto = "yes"; count = 5; separator = ";"; }; replace = { "[\\\\/]" = "_"; "^\\." = "_"; "[\\x00-\\x1f]" = "_"; "\\.$" = "_"; "\\s+$" = ""; "^\\s+" = ""; "^-" = "_"; }; import = { incremental = "yes"; bell = "yes"; languages = "en"; }; item_fields = { disc_and_track = "u'%02i.%02i' % (disc, track) if disctotal > 1 else u'%02i' % (track)"; primary_albumartist = # python '' if albumartist.lower().strip().startswith(albumartists[0].lower().strip()): return albumartists[0] else: return None ''; }; paths = { default = "%ifdef{primary_albumartist, $primary_albumartist, $albumartist}/$album%aunique{}/$disc_and_track - $artist - $title"; }; }; }; }; }