about summary refs log tree commit diff stats
path: root/modules/home/conf/beets/default.nix
blob: 87c4de8bb7517c2316dae2f03b9e23d7a5645b5d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
{
  pkgs,
  config,
  ...
}: {
  programs.beets = {
    enable = true;
    package = pkgs.beets.override {
      pluginOverrides = {
        beatport.enable = true;
      };
    };
    settings = {
      library = "${config.xdg.dataHome}/beets/library.db";
      art_filename = "cover";
      directory = "${config.xdg.userDirs.music}/beets";
      ui = {
        color = true;
      };
      import = {
        # link, instead of copying or moving the files
        copy = false;
        move = false;
        link = true;

        # Show more detail, when beet needs to ask for something
        detail = true;

        # Don't try to import already imported directories
        incremental = true;

        # Write the metadata to the files
        write = true;
        log = "beetslog.txt";
      };

      paths = {
        default = "$genre/$albumartist/$album/$track $title";
        comp = "$genre/$album/$track $title";
        singleton = "$genre/$artist/$title";
        "albumtype:soundtrack" = "Soundtracks/$album/$track $title";
      };

      # Plugin config
      lastgenre = {
        prefer_specific = false;
        # Lookup the track, not the album
        source = "track";
      };
      fetchart = {};
      lyrics = {
        # Always fetch lyrics (and update them, if some were found)
        force = true;
      };
      hook = {
        hooks = [
          {
            # Called, when `beet import` finishes
            event = "import";
            command = "echo 'Import finished. Starting to calculate replay gain..'";
          }
          {
            # Called, when `beet import` finishes
            event = "import";
            command = "beet replaygain";
          }
        ];
      };
      replaygain = {
        # Can't run in parallel in the import because of writing issues, thus we run it
        # after the import finishes (see the `hooks` config)
        auto = false;
        backend = "ffmpeg";

        # Re-calculate the replay gain value even for files, that already have one set.
        overwrite = true;
      };
      # scrub = {
      #   auto = true;
      # };

      plugins = [
        # Remove all previous tags before import (this is useful to ensure, that
        # the metadata in the libary.db is synced with the tags on disk)
        # # FIXME: I think, that this also removes the baked-in images, which is not ideal
        # <2024-08-07>
        # "scrub"

        # Calculate replay gain
        "replaygain"

        # Generate fingerprints
        "chroma"

        # Download album art
        "fetchart"

        # Fetches tags from `last.fm` and adds them as genres to imported music
        "lastgenre"

        # Run commands on events
        "hook"

        # Fetch lyrics
        "lyrics"

        # Allow beets to understand deezer id's
        "deezer"

        "mpdstats" # Transfer MPD stats to beets
        "mpdupdate" # Update MPD database on import
      ];

      musicbrainz = {
        # Search for deezer id's and use them in the autotagger
        external_ids = {
          deezer = true;
        };
      };

      # Log-on config
      # TODO: Add this, to upload the generated fingerprints (to help improve their
      # database) <2024-08-07>
      # acoustid = {
      #   apikey = "TODO";
      # };
    };

    mpdIntegration = {
      enableStats = true;
      enableUpdate = true;
      host = config.home.sessionVariables.MPD_HOST;
    };
  };
}