Commit graph

12988 commits

Author SHA1 Message Date
J0J0 Todos
18e76f08c7 Prevent album genre inherit only when source:track
is configured.
2025-01-07 01:54:17 +01:00
J0J0 Todos
9ec2a8146f Streamline lastgenre singleton log with album log
It was rather confusing that the lastgenre plugin, when handling
singletons, sometimes showed that it applied genres from last.fm and
sometimes didn't (it did only in debug log). This streamlines the
behaviour:

- Change debug to info log.
- Streamline wording.
- Display details about the track.
2025-01-07 01:54:17 +01:00
J0J0 Todos
d4ada3ce43 Fix track-level genre handling in lastgenre plugin
When `lastgenre.source: track` is configured,

- `lastgenre -a` _should not_ fall back to the album level genre (by
  making use of the with_album=False kwarg of the Libary's get method).
- `lastgenre -a`, when finally storing the genres of _an album_, should
  _not_ also write the tracks genres (by making use of the inherit=False
  kwarg of the Album's store method.
2025-01-07 01:53:58 +01:00
Šarūnas Nejus
801bac5f9e
Release: Fix changelog formatting (#5529)
# Improve release notes formatting / changelog conversion from rst to md

During our last release, we discovered issues with changelog formatting.
This PR improves and fixes several aspects:

## Changes
- Rewrite the changelog conversion logic to be more robust and
maintainable
- Fix indentation issues with nested bullet points
- Improve handling of long section headers
- Order bullet points alphabetically within sections for better
readability
- Use Sphinx `objects.inv` to resolve references and include links to
the documentation in _Markdown_
- Add tests to prevent formatting regressions
- Add pandoc as a dependency for Ubuntu CI builds
- Ensure documentation is built before generating changelog
2025-01-04 01:46:01 +00:00
Šarūnas Nejus
c01d0591f5
Fix track matching regression (#5571)
## Problem
A regression was introduced when adjusting the track matching logic to
use `lapjv` instead of `munkres`. The `lapjv` algorithm returns `-1` for
unmatched items, which wasn't being handled correctly in the matching
logic. This caused incorrect track assignments when importing new music.

## Solution
- Modified the mapping creation to filter out unmatched items (where
index is `-1`)
- Updated test case to properly catch this scenario
2025-01-04 01:42:35 +00:00
Šarūnas Nejus
f91f0961f5
Fix sorting on missing non-string fields (#5570)
## Description

Fixes #5512. When sorting on a field, if the field is missing from some
items and it has a type, use the type's `null` value. Otherwise,
continue to fall back to an empty string, as I don't think there's much
to be done in that case.

The new test `test_int_field_present_in_some_items` fails without the
fix in `query.py`.
2025-01-01 01:41:02 +00:00
valrus
c9afb8664b Add types-mock for typechecking 2024-12-31 17:22:53 -08:00
valrus
80a10c7e4e lint 2024-12-31 15:14:32 -08:00
valrus
7f469eea54 format 2024-12-31 15:13:42 -08:00
valrus
ef00b1cd22 simplify non-string missing field condition 2024-12-31 15:13:00 -08:00
valrus
342ac283b6 improve names 2024-12-31 15:10:50 -08:00
valrus
21c734bff8 patch rather than overwriting Item 2024-12-31 14:50:44 -08:00
Šarūnas Nejus
ef902ea14f
item assignment: set track distance configuration in tests explicitly
These tests depend on certain `track_length_grace` and
`track_length_max` configuration which was set by other tests in this
module.

I discovered this issue when I tried to run
`test_order_works_when_track_names_are_entirely_wrong` test only
- I found that my local configuration was read and the test failed.
2024-12-31 08:13:13 +00:00
Šarūnas Nejus
084cf6490e
matching: add additional test cases and refactor tests 2024-12-31 08:12:03 +00:00
Šarūnas Nejus
0d6393e712
Fix track matching
I had previously tested the `munkres` -> `lapjv` replacement
extensively, so I was today surprised to find that nothing gets matched
correctly when I tried importing some new tracks.

On the other hand I now remember making a small adjustment in the logic
to make autotagging tests pass which is when I introduced a bug: I did
not realize that `lapjv` returns index '-1' for each unmatched item.

This issue did not get caught by tests because this 'unmatched' item
index '-1' anecdotally ended up pointing to the last (expected) item in
the test making it pass.

This commit adjusts the aforementioned test to catch this issue and
fixes the logic to correctly identify unmatched tracks.
2024-12-31 00:08:10 +00:00
valrus
e9a77cac72 format 2024-12-29 08:08:54 -08:00
valrus
723e928d79 Add changelog item 2024-12-29 08:08:25 -08:00
valrus
1af9df2b40 add another benefit of item_types 2024-12-29 08:04:50 -08:00
valrus
5882e2cf67 Fix sorting on missing int fields 2024-12-29 08:01:41 -08:00
Šarūnas Nejus
fdd365f88d
Future proof BucketPluginTest.test_year_single_year_last_folder (#5566)
2025 won't be in the future, forever.

Fixes: https://bugs.debian.org/1091495
2024-12-29 13:34:38 +00:00
Šarūnas Nejus
eb557f720d
Resolve all URLs for markdown 2024-12-28 07:26:04 +00:00
Šarūnas Nejus
555cf322db
Remove the temporary testing workflow 2024-12-28 07:26:04 +00:00
Šarūnas Nejus
0f45791f3a
Fix Unreleased changelog template 2024-12-28 07:26:03 +00:00
Šarūnas Nejus
e579df0a98
Can we link users to plugin docs? 2024-12-28 07:24:23 +00:00
Šarūnas Nejus
779ba791f9
Cap maximum sub-section name length 2024-12-28 07:24:23 +00:00
Šarūnas Nejus
0b905e1b17
Ignore literal code blocks when making headers 2024-12-28 07:24:23 +00:00
Šarūnas Nejus
6d602effc3
Add a test for literal code block 2024-12-28 07:24:23 +00:00
Šarūnas Nejus
806c1702fb
Fix wrapped line starting with the username role 2024-12-28 07:24:23 +00:00
Šarūnas Nejus
89afb8cd89
Test wrapped line starting with the username role 2024-12-28 07:24:23 +00:00
Šarūnas Nejus
c26473e6cb
Fix nested bullet points conversion 2024-12-28 07:24:23 +00:00
Šarūnas Nejus
dd96928f38
Test nested bullet points conversion 2024-12-28 07:24:22 +00:00
Šarūnas Nejus
d98226aa07
Fix ordering bullet point lists 2024-12-28 07:24:22 +00:00
Šarūnas Nejus
7b9625bc86
Test rst to md conversion 2024-12-28 07:24:22 +00:00
Šarūnas Nejus
13e83cdce3
🤦 2024-12-28 07:24:22 +00:00
Šarūnas Nejus
914dbcb420
Cache deps 2024-12-28 07:24:22 +00:00
Šarūnas Nejus
e9076ffb53
Unindent list items in the changelog
I found out that GitHub Actions use pandoc version 2.9.2.1 which
converts bullet points like this:

echo '
* Item
* Another item
' | pandoc --from=rst --to=gfm
  - Item
  - Another item

Note that each item has two-space indent. Meanwhile, locally I've been
testing this conversion using pandoc 3.5 which does not add any indent:

echo '
* Item
* Another item
' | pandoc --from=rst --to=gfm
- Item
- Another item

This commit removes the indent and cleans up the how the replacements in
rst and md text are performed.
2024-12-28 07:24:22 +00:00
Šarūnas Nejus
aff43d8d62
Remove poe output 2024-12-28 07:24:22 +00:00
Šarūnas Nejus
ef4e98389c
Add test for changelog formatting 2024-12-28 07:24:17 +00:00
Stefano Rivera
bcc79a5b09 Future proof BucketPluginTest.test_year_single_year_last_folder
2025 won't be in the future, forever.

Fixes: https://bugs.debian.org/1091495
2024-12-27 16:28:38 -04:00
Šarūnas Nejus
faf7529aa9
Replace munkres with lapjv for track assignment (#5564)
Fixes #5207.

This PR replaces the `munkres` library with `lap` (Linear Assignment
Problem solver) for computing optimal track assignments during the
auto-tagging process. The main changes are:

- Remove `munkres` dependency and add `lap` and `numpy` dependencies
- Refactor the track assignment code to use `lap.lapjv()` instead of
`Munkres().compute()`
- Simplify cost matrix construction using list comprehension
- Move config value reading outside of `track_distance` function to
improve performance

The motivation for this change comes from benchmark comparisons showing
that LAPJV (implemented in the `lap` library) significantly outperforms
the Munkres/Hungarian algorithm for the linear assignment problem. See
detailed benchmarks at: https://github.com/berhane/LAP-solvers

The change should provide better performance for track matching,
especially with larger albums, while maintaining the same assignment
results.

## Testing Notes
- All existing tests pass without modification
- Track assignments produce identical results 
- No behavioral changes in auto-tagging
2024-12-27 17:27:28 +00:00
Šarūnas Nejus
4c8d75ff38
Cache track_length_grace and track_length_max access 2024-12-27 16:22:24 +00:00
Šarūnas Nejus
420117b598
Track assignment: replace munkres with lapjv
See the following comparison between several implementations to solve
this problem: https://github.com/berhane/LAP-solvers
2024-12-27 10:16:28 +00:00
Šarūnas Nejus
2277e2a0d9
Use shutil.move() to move files. (#5123)
Fixes #4622.

I don't think this changes other behavior of the function, but it fixes
the problem with the moved files being created with the wrong
permissions for me.
2024-12-26 18:45:21 +00:00
Aidan Epstein
34af24bbf7 Add some error ignoring for copystat call in move() 2024-12-19 16:43:41 -08:00
Šarūnas Nejus
bcf516b81d
Properly type db on the model, sort out generic types issues (#5545)
Thanks to @wisp3rwind's suggestion this PR adds types to the
relationship between `Model`, `Database` and `Library`.

Then I worked through the rest of the issues found in the edited files.
Most of this involved providing type parameters for generic types (or
defining defaults, rather 😉).

There `queryparse` module had a somewhat significant issue where the
sorting construction logic only expected to receive `FieldSort`
subclasses, while `SmartArtistSort` was not one. Thus `SmartArtistSort`
has now been forced to behave and is a `FieldSort` subclass. It's also
been moved to `query.py` module which is where the rest of sorts are
defined.
2024-12-19 16:46:38 +00:00
Arsen Arsenović
994f9b83f1 pyproject.toml: don't install docs et al into the wheel
wheels are directly unpacked into site-packages, so this means likely
conflict with other packages
2024-12-19 05:12:04 +00:00
Šarūnas Nejus
9110a1110b
Stop perpetually writing mb_artistid, mb_albumartistid and albumtypes fields (#5540)
This PR fixes an issue where the `beet write` command repeatedly shows
differences for certain fields (`mb_artistid`, `mb_albumartistid`,
`albumtype`) even after writing the tags.
This happens because these fields are actually stored as lists in the
media files (`mb_artistids`, `mb_albumartistids`, `albumtypes`), but
beets maintains both single and list versions in its database.

This PR addresses this issue in a non-invasive way: the fix ensures
consistency between single fields and their list counterparts by:
1. When setting a single field value, making it the first element of the
corresponding list
2. When setting a list, using its first element as the single field
value

This resolves long-standing issues #5265, #5371, and #4715 where users
experienced persistent "differences" in these fields despite writing
tags multiple times.

Changes:
- Added `ensure_consistent_list_fields()` function to synchronize field
pairs
- Applied this function during metadata application
- Added tests for all field combinations

Fixes #5265, #5371, #4715

**Note**: your music needs to be reimported with `beet import -LI` or
synchronised with `beet mbsync` in order to fix these fields!
2024-12-15 14:17:22 +00:00
Šarūnas Nejus
3b0c47799b
Define unique_list and dedupe 2024-12-15 13:22:07 +00:00
Šarūnas Nejus
a091c2eeae
Ensure that list fields are corrected for album metadata too 2024-12-15 00:12:36 +00:00
Šarūnas Nejus
550a9a82b1
Fix mb_artistid, mb_albumartistid, albumtype diff issue 2024-12-14 21:39:47 +00:00