beets-genrecanon
beets-genrecanon is a beets plugin that maps detailed source genres to
user-defined canonical genre categories.
It preserves the original genre value and stores the broader category
separately as genre_canon. This makes it possible to build consistent
genre-based playlists without replacing useful metadata or relying on an
online genre service.
The initial release supports FLAC files only.
Why use it?
MusicBrainz and other tag sources may describe similar music using many different genres. For example:
Rock:
- Progressive Rock
- Symphonic Rock
- Classic Rock
The original genre remains unchanged, while the plugin writes:
GENRE=Symphonic Rock
GENRE_CANON=Rock
The canonical categories and mappings are entirely controlled by the user.
Features
- Preserves the original
GENREtag. - Writes a separate
GENRE_CANONFLAC tag. - Stores the value in the beets
genre_canonflexible field. - Uses a fully customizable
genres.yamltaxonomy. - Detects missing, stale, and duplicate
GENRE_CANONvalues. - Does not rewrite tags that already match.
- Prompts the user when an unknown genre is encountered.
- Updates
genres.yamlonly after the proposed mappings are confirmed. - Validates the complete import before modifying any FLAC files.
- Supports beets import pretend mode.
- Performs parallel metadata reads using the available logical CPUs.
- Requires no network service.
Installation
Install from PyPI into the same Python environment as beets:
python -m pip install beets-genrecanon
For development, clone the repository and install it in editable mode:
python -m pip install -e '.[test]'
Enable the plugin in the beets configuration:
plugins:
- genrecanon
Configuration
genrecanon:
auto: yes
mapping: ~/.config/beets/genres.yaml
threads: 16
Options:
auto: Run canonicalization automatically at the beginning of an import.mapping: Location of the user-maintained genre taxonomy.threads: Number of concurrent FLAC metadata readers. If omitted, the default is the number of logical CPUs available to Python.
The default mapping location is genres.yaml in the beets configuration
directory. The exact directory varies by platform.
Starting a new taxonomy
Create genres.yaml from the packaged starter taxonomy:
beet genrecanon --init
The file is created at the location specified by genrecanon.mapping. If no
location is configured, it is created as genres.yaml in the beets
configuration directory.
The command refuses to overwrite an existing mapping file.
The taxonomy is intended to be customized. Categories may be renamed, added, removed, or reorganized as desired.
Importing music
Run a normal as-is import:
beet import -A /path/to/music
Before beets imports the files, the plugin:
- Reads all FLAC metadata under the import path.
- Determines the expected canonical genre for each file.
- Leaves already-correct files untouched.
- Reports genres that are missing from
genres.yaml. - Allows unknown genres to be assigned to an existing or new category.
- Confirms and atomically updates
genres.yaml. - Revalidates the affected files.
- Writes only missing, stale, or duplicate
GENRE_CANONtags. - Copies
GENRE_CANONinto the beetsgenre_canonfield during import.
The plugin does not begin writing FLAC tags while unresolved genres remain.
Pretend mode
Preview an import without changing genres.yaml, FLAC files, or the beets
database:
beet import -A --pretend /path/to/music
Pretend mode reports files that are unchanged, would be updated, contain unmapped genres, or could not be read. It does not prompt for classifications.
Synchronizing existing library items
Synchronize embedded GENRE_CANON tags into the beets database:
beet genrecanon
Limit synchronization with a beets query:
beet genrecanon 'path:/path/to/music'
Preview the database changes:
beet genrecanon -p 'path:/path/to/music'
This command does not derive genres or modify FLAC tags. It synchronizes
existing embedded GENRE_CANON values into the beets database.
Querying canonical genres
List tracks assigned to a canonical genre:
beet ls 'genre_canon:Rock'
Display both genre fields:
beet ls -f '$artist - $title | genre=$genre | genre_canon=$genre_canon'
Platform support
The plugin is written entirely in Python and is intended to work wherever beets, Mutagen, and PyYAML are available, including Linux, macOS, and Windows.
Only FLAC tag canonicalization is currently supported.
License
GNU General Public License, version 2 or later.
Release files for beets-genrecanon 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| beets_genrecanon-0.1.1.tar.gz | 23.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| beets_genrecanon-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 43.2 kB
Release files / beets_genrecanon-0.1.1.tar.gz
| Download URL | beets_genrecanon-0.1.1.tar.gz |
|---|---|
| Size | 23.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f976de452700716dac508e9787533bdce9a017c683198986b2b255cacd5d5952
|
|
BLAKE2b-256 checksum How to use checksums |
454fa60ce7637ee21140977953ad8d436a404df37ffd62887d1096f07ddbcc1e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / beets_genrecanon-0.1.1-py3-none-any.whl
| Download URL | beets_genrecanon-0.1.1-py3-none-any.whl |
|---|---|
| Size | 19.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
62b7a3e6aa51e40ef65ed2fa1152bbc2b51452d1015aa790e7d11118d4a291a5
|
|
BLAKE2b-256 checksum How to use checksums |
2c6fcfaa260ffad4161754c13f7b36abc418ef99d47ebeb27cd9b58886d4731a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|