Add %tunique{} path template function for track disambiguation within albums#6722
Open
arsaboo wants to merge 7 commits into
Open
Add %tunique{} path template function for track disambiguation within albums#6722arsaboo wants to merge 7 commits into
arsaboo wants to merge 7 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a new %tunique{} path template and configuration to disambiguate tracks with identical titles within the same album.
Changes:
- Introduces
tmpl_tuniqueand aqueryoverride hook in_tmpl_uniqueto scope ambiguity checks to an album. - Adds defaults for
tuniqueinconfig_default.yamland documents the new template/config. - Adds a new test suite covering
%tunique{}behavior and edge cases.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/test_library.py | Adds %tunique{} test coverage for album-scoped track title collisions and formatting options. |
| docs/reference/pathformat.rst | Documents the new %tunique{} template and its default identifiers/disambiguators. |
| docs/reference/config.rst | Documents new tunique config keys and defaults. |
| docs/changelog.rst | Adds changelog entry announcing %tunique{}. |
| beets/library/models.py | Implements tmpl_tunique and extends _tmpl_unique with an optional pre-built query. |
| beets/config_default.yaml | Adds default configuration for tunique. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6722 +/- ##
==========================================
- Coverage 75.63% 75.63% -0.01%
==========================================
Files 162 162
Lines 20820 20835 +15
Branches 3298 3302 +4
==========================================
+ Hits 15747 15758 +11
- Misses 4292 4294 +2
- Partials 781 783 +2
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new
%tunique{}path template function (analogous to%aunique{}for albums and%sunique{}for singletons) that disambiguates tracks within the same album that would otherwise produce identical filenames (e.g., two tracks with the same title on the same album or across different discs). This follows the structure and logic used inauniqueorsunique.Fixes #5950
Default configuration:
The function first finds all sibling items (same
album_id) with matching key values (default: sametitle). If duplicates exist, it iterates through the disambiguator fields looking for one that uniquely separates all duplicates. If no field suffices, the stable database ID is used as a fallback. For items without a duplicate, no suffix is added.This solves the problem where
beet movewould non-deterministically append .1/.2 suffixes viaunique_path()for duplicate-titled tracks, which would change every time the command was re-run.Example usage in path config:
For an album with two identically-titled tracks:
To Do
docs/to describe it.)docs/changelog.rstto the bottom of one of the lists near the top of the document.)