Fixes a bug where existing tags were set to None, if they weren't whitelisted, but an whitelisted canonicalized parent existed up the tree.
In all other cases, the original genres are canonicalized and considered for the final genre, except in the keep_existing logic branch.
This PR fixes the issue and results in the expected behavior for this combination of options.
For the bug to trigger several conditions had to be met:
- Canonicalization is enabled and a whitelist is specified.
- `force` and `keep_existing` are set. Meaning, that Lastfm is queried for a genre, but the existing genres are still left around when none are found online.
- A release with a non-whitelisted genre exists, but that genre has a whitelisted genre parent up the tree.
- That very release has no genre on lastfm.
This is rather convoluted, but stay with me :D
What would happen is the following:
- `keep_genres` is set to the existing genres, as `force` and `keep_existing` is set.
- Genres for `track`/`album`/`artist` aren't found for this release, as they don't exist in lastfm.
- Then the `keep_existing` logic is entered.
- The old logic only checks if the existing genres have an **exact** match for the whitelist. In contrast to all other code branches, we don't do the `_try_resolve_stage` in case there's no direct match, resulting in no match.
- We continue to the fallback logic, which returns the fallback (`None` in my case)
This patch results in one last try to resolve the existing genres when `keep_existing` is set, which includes canonicalization (if enabled).
Creating indexes turned out to be relatively straightforward!
While we can’t remove them yet, that doesn’t seem necessary for now.
Interestingly, much of the infrastructure for database additions was
already in place.
- This PR introduces a new type, `Index`, which can be used to create an
index on any defined table. 🎉
- The `items` table now automatically registers an index on `album_id`
Closes#5809
The `beets/random.py` module was only used by the random plugin, so I
moved its functions into `beetsplug/random.py` to keep core modules
cleaner.
Changes:
- Moved beets/random.py functions into beetsplug/random.py
- Added typehints for better readability and tooling support
- Added additional tests for improved coverage
- General tidy up and refactor, keeping the core functionality unchanged
- Handle list-valued fields when grouping for --field/--equal-chance to avoid
"TypeError: unhashable type: 'list'" (e.g., artists).
- Sort items by the grouping key before building groups so equal-chance
permutation preserves the same item set as `beet list`, only randomized.
Here some changes which I made when works on #5342 , I think we may say
that it actually fixes#5342 because after that we have full colors in
docs and code which allows user to do colours as he would like to.
Normally, the Fish completion plugin won't complete filenames, which is
useful for `beet import` and similar! This removes the `-f` (no filename
completion) flag from various places in the output.
This PR adds support for
[mp3rgain](https://github.com/M-Igashi/mp3rgain) as an alternative to
mp3gain/aacgain in the ReplayGain plugin's command backend.
## What is mp3rgain?
mp3rgain is a modern Rust rewrite of mp3gain that provides:
- **CLI-compatible drop-in replacement** for mp3gain - same command-line
interface and output format
- **Support for both MP3 and AAC/M4A formats** (like aacgain)
- **Security fixes** for vulnerabilities in the original mp3gain:
- CVE-2021-34085 (Critical, CVSS 9.8) - buffer over-read in
`WriteMP3GainAPETag`
- CVE-2019-18359 (Medium, CVSS 5.5) - buffer over-read in
`ReadMP3APETag`
- **Memory-safe implementation** in Rust
- **Works on modern systems** including Windows 11 and macOS with Apple
Silicon
- **Active maintenance** (original mp3gain has not been updated since
2009)
## Changes
1. **beetsplug/replaygain.py**:
- Add `mp3rgain` to the command search list (prioritized first since
it's more secure)
- Update `format_supported()` to correctly handle mp3rgain's AAC/M4A
support
- Update error message to mention mp3rgain
2. **docs/plugins/replaygain.rst**:
- Add mp3rgain to the backend documentation
- Include installation instructions for various platforms
- Document the security benefits
## Testing
mp3rgain has been tested to be fully compatible with the existing
command backend:
- Supports all the same command-line flags (`-o`, `-s s`, `-k`, `-c`,
`-d`, etc.)
- Produces identical tab-delimited output format
- Returns the same exit codes
## Why prioritize mp3rgain in the search order?
The original mp3gain has known security vulnerabilities that have not
been fixed (the project has been inactive since 2009). By searching for
mp3rgain first, users who have it installed will automatically benefit
from the security improvements, while maintaining full backward
compatibility for users who only have mp3gain/aacgain installed.