Commit graph

12644 commits

Author SHA1 Message Date
Š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
Šarūnas Nejus
22163d70a7
Remove support for Python 3.8 (#5508)
- Drop support for EOL Python 3.8 making Python 3.9 the minimum
supported version

- Take advantage of Python 3.9+ type hint syntax by:
  - Using `list[T]` instead of `List[T]` etc. from typing module
  - Using `Type | None` syntax for unions instead of `Union[Type, None]`
  - Moving collection type hints from `typing` to `collections.abc`
  - Using `TYPE_CHECKING` guard for runtime import optimization

Note: in #5503 we found that we cannot support Python 3.12 unless we
upgrade our minimum support Python to 3.9.
2024-12-10 06:54:23 +00:00
Šarūnas Nejus
5c81f94cf7
Move imports required for typing under the TYPE_CHECKING block 2024-12-10 06:10:04 +00:00
Šarūnas Nejus
161b0522bb
Update deprecated imports 2024-12-10 06:10:04 +00:00
Šarūnas Nejus
7ef1b61070
Replace Union types by PEP604 pipe character 2024-12-10 06:10:04 +00:00
Šarūnas Nejus
fbfdfd5444
Remove unnecessary quotes from types 2024-12-10 06:10:04 +00:00
Šarūnas Nejus
51f9dd229e
Use PEP585 lowercase collections typing annotations 2024-12-10 06:10:03 +00:00
Šarūnas Nejus
7be8f9c97a
Update CI config, minimum ruff version, docs and add changelog note 2024-12-10 06:10:03 +00:00
Šarūnas Nejus
88deb07890
Drop Python 3.8 from the package, update dependencies 2024-12-10 06:08:14 +00:00
Šarūnas Nejus
3cc129b893
Package: fix release workflow, exclude plugin tests, include all files from MANIFEST.in (#5536)
Fixes #5526
Fixes #5531
Fixes #5539

### Package contents

See #5526 where a package maintainer fails running plugin tests. I found that before
introduction of Poetry `beets` never bundled plugin tests, therefore I now excluded them.

I also remembered that previously `MANIFEST.in` file was used to specify which files get
included in the package, so I mirrored the same configuration. This includes zsh
completion in `extra/_beet` which fixes #5531.

I removed `MANIFEST.in` file since it has no use anymore.

### Release workflow

The last release workflow run failed to pick up the commit with the version updates and
tagged an outdated commit (#5539). I simplified the workflow to create the tag at the same
time the version upgrade is committed.
2024-12-10 05:58:48 +00:00
Šarūnas Nejus
71eb1bca68
Release: create tag right after commit version update 2024-12-10 05:51:13 +00:00
Šarūnas Nejus
ed3a53f2fe
Exclude plugin tests, include all files from MANIFEST.in 2024-12-10 05:51:09 +00:00
Šarūnas Nejus
af41eef776
lyrics: Fallback to plain lyrics if synced lyrics not available (#5089)
The `synced` config flag was not working the way the docs described it
for the LRCLIB source. With `synced: yes`, if a track does not have
synced lyrics, but does have plain lyrics, the plugin would return no
lyrics. The docs imply that, with the flag enabled, it would still use
plain lyrics if there are no synced lyrics.

LRCLIB API call that returns plain lyrics can be found
[here](https://lrclib.net/api/get?artist_name=Hania%20Rani&track_name=Moans&album_name=Ghosts&duration=274).
2024-12-07 17:54:40 +00:00
Edgars Supe
09360259cc lyrics: Fallback to plain lyrics if synced not available 2024-12-07 19:08:37 +02:00
Šarūnas Nejus
755e825928
ARM install instructions (#5460)
Add info for ARM installs.
2024-12-05 11:43:02 +00:00
RollingStar
40987902df
Update main.rst 2024-12-04 19:56:57 -05:00
RollingStar
eafae03560
Merge branch 'beetbox:master' into arm-info 2024-12-04 19:56:26 -05:00
snejus
f92c0ec8b1 Increment version to 2.2.0 2024-12-02 06:56:49 +00:00
Šarūnas Nejus
01f1fafc88
Release: do not fail when mastodon auth fails 2024-12-02 06:55:56 +00:00
Šarūnas Nejus
27d66d4b36
Change zero documentation mentions of genre to genres (#5486)
I've spent 2 hours troubleshooting why none of my music had genre tag.
It was because the single `genre`, without `s` doesn't seem to cover any
good ganre tags... at least it didn't on my opus files

looking at the code:
7ecd86101e/mediafile.py (L1669-L2167)
i don't honestly know why anyone created the single `ganre` field in the
first place
2024-12-02 02:21:08 +00:00
Šarūnas Nejus
242d0e8cf3
Include tests and manual in sdist and update dependencies, and include changelog to the release (#5520)
* Fixes #5513
* Fixes #5518

This PR adds the `test` folder and manuals to the package source tarball
and upgrades the dependencies to fix a few vulnerabilities.

I also added a fix for the changelog not making it to the release notes.
2024-12-02 00:08:16 +00:00
Šarūnas Nejus
0eab8b68dd
Skip autobpm tests if librosa isn't available (#5516)
Debian doesn't have `librosa`. Allow the tests to continue.
2024-11-30 15:35:00 +00:00
Stefano Rivera
336b5b369e Skip autobpm tests if librosa isn't available
Except under GitHub CI, where we expect all tests to run.
2024-11-30 09:32:08 -04:00
Šarūnas Nejus
f39eb984ca
Update dependencies 2024-11-26 16:06:29 +00:00
Šarūnas Nejus
a7f00eaf13
Fix missing changelog in the release notes
Seems like this is the missing bit:
https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#using-job-outputs-in-a-matrix-job
2024-11-26 15:59:41 +00:00
Šarūnas Nejus
f5a02462b1
Fixup changelog rst formatting for this and prev version 2024-11-26 15:45:58 +00:00
Šarūnas Nejus
9c4d4d9632
Include test files, manual to sdist 2024-11-26 15:38:13 +00:00
Šarūnas Nejus
37a2ceccd1
Fix coverage upload from forks: Attempt #2 (#5514)
The fix is based on the following comment:

https://github.com/codecov/codecov-action/issues/1594#issuecomment-2394913029
2024-11-23 20:48:35 +00:00
Šarūnas Nejus
0e6ba457a6
Fix Hybrid SACD importing (#5149)
Fixes #5148. 

When importing, the code that matches tracks does not consider the
medium number. This causes problems on Hybrid SACDs (and other releases)
where the artists, track numbers, titles, and lengths are the same on
both layers.

I added a distance penalty for mismatching medium numbers.

Before:

```
$ beet imp .

/Volumes/Music/ti/Red Garland/1958 - All Mornin' Long - 1 (6 items)

  Match (95.4%):
  The Red Garland Quintet - All Mornin' Long
  ≠ media, year
  MusicBrainz, 2xHybrid SACD (CD layer), 2013, US, Analogue Productions, CPRJ 7130 SA, mono
  https://musicbrainz.org/release/6a584522-58ea-470b-81fb-e60e5cd7b21e
  * Artist: The Red Garland Quintet
  * Album: All Mornin' Long
  * Hybrid SACD (CD layer) 1
     ≠ (#2-1) All Mornin' Long (20:21) -> (#1-1) All Mornin' Long (20:21)
     ≠ (#2-2) They Can't Take That Away From Me (10:24) -> (#1-2) They Can't Take That Away From Me (10:27)
     ≠ (#2-3) Our Delight (6:23) -> (#1-3) Our Delight (6:23)
  * Hybrid SACD (CD layer) 2
     ≠ (#1-1) All mornin' long (20:21) -> (#2-1) All Mornin' Long (20:21)
     ≠ (#1-2) They can't take that away from me (10:27) -> (#2-2) They Can't Take That Away From Me (10:25)
     ≠ (#1-3) Our delight (6:23) -> (#2-3) Our Delight (6:23)
➜ [A]pply, More candidates, Skip, Use as-is, as Tracks, Group albums,
Enter search, enter Id, aBort, eDit, edit Candidates?
```

Note that all tracks tagged with disc 1 get moved to disc 2 and vice
versa.

After:

```
$ beet-test imp .

/Volumes/Music/ti/Red Garland/1958 - All Mornin' Long - 1 (6 items)

  Match (95.4%):
  The Red Garland Quintet - All Mornin' Long
  ≠ media, year
  MusicBrainz, 2xMedia, 2013, US, Analogue Productions, CPRJ 7130 SA, mono
  https://musicbrainz.org/release/6a584522-58ea-470b-81fb-e60e5cd7b21e
  * Artist: The Red Garland Quintet
  * Album: All Mornin' Long
  * Hybrid SACD (CD layer) 1
     ≠ (#1-1) All mornin' long (20:21) -> (#1-1) All Mornin' Long (20:21)
     ≠ (#1-2) They can't take that away from me (10:27) -> (#1-2) They Can't Take That Away From Me (10:27)
     ≠ (#1-3) Our delight (6:23) -> (#1-3) Our Delight (6:23)
  * Hybrid SACD (SACD layer) 2
     * (#2-1) All Mornin' Long (20:21)
     * (#2-2) They Can't Take That Away From Me (10:24)
     * (#2-3) Our Delight (6:23)
➜ [A]pply, More candidates, Skip, Use as-is, as Tracks, Group albums,
Enter search, enter Id, aBort, eDit, edit Candidates?
```

Yay!
2024-11-23 04:04:30 +00:00
InvisibleFunction
32e9e58a35 Fix SACD Imports 2024-11-22 22:33:09 -05:00
Šarūnas Nejus
db71444fe7
Disable OIDC for coverage uploads from forks
This is based on the following comment:
https://github.com/codecov/codecov-action/issues/1594#issuecomment-2394913029
2024-11-23 01:13:16 +00:00
RollingStar
79d7d48fe0
ARM footnotes 2024-11-22 17:43:52 -05:00
RollingStar
5f4fe21237
Update docs/guides/main.rst
Co-authored-by: Šarūnas Nejus <snejus@protonmail.com>
2024-11-22 17:38:07 -05:00
Šarūnas Nejus
ef328ed740
Add a quick check for MST Store Python install (#5470)
Quick fix for #5467.

Checks if the path for python is under the windows store folder then
error and point the user to the beets
[documentation](https://beets.readthedocs.io/en/stable/guides/main.html).

Happy for feedback to improve, but thought it best to exit as early as
possible.
2024-11-22 13:46:09 +00:00
Andrew Rogl
1d63bf9871 Update error logging as suggested 2024-11-22 18:07:28 +10:00
Andrew Rogl
ec4b26f986 Update changelog 2024-11-22 18:07:18 +10:00
Andrew Rogl
22810b6720 Windows & VSCode & Python 2024-11-22 18:04:43 +10:00
Andrew Rogl
3750c63fb6 Manually format messages 2024-11-22 18:04:43 +10:00
Andrew Rogl
f0f77aa741 Update related window files to match 3.8 2024-11-22 18:04:43 +10:00
Andrew Rogl
3798ac5d02 Add a quick check for MST Store Python install 2024-11-22 18:04:43 +10:00
Šarūnas Nejus
176661bbf8
Changelog notes need to go under Unreleased 2024-11-22 07:18:14 +00:00
Šarūnas Nejus
6444111cde
bitesize to good first issue: Update changelog.rst (#5477) 2024-11-22 05:05:39 +00:00
Šarūnas Nejus
65e935bee5
Perform a regex substitution in the substitute plugin (#5357)
This utilises regex substitution in the substitute plugin. The previous
approach only used regex to match the pattern, then replaced it with a
static string. This change allows more complex substitutions, where the
output depends on the input.

### Example use case
Say we want to keep only the first artist of a multi-artist credit, as
in the following list:
```
Neil Young & Crazy Horse -> Neil Young
Michael Hurley, The Holy Modal Rounders, Jeffrey Frederick & The Clamtones -> Michael Hurley
James Yorkston and the Athletes -> James Yorkston
````
This would previously have required three separate rules, one for each
resulting artist. By using a regex substitution, we can get the desired
behaviour in a single rule:
```yaml
substitute:
  ^(.*?)(,| &| and).*: \1
```
(Capture the text until the first `,` ` &` or ` and`, then use that
capture group as the output)

### Notes
I've kept the previous behaviour of only applying the first matching
rule, but I'm not 100% sure it's the ideal approach.
I can imagine both cases where you want to apply several rules in
sequence and cases where you want to stop after the first match.
2024-11-22 05:02:50 +00:00
Šarūnas Nejus
979f1239ca
Revert "Release: temporarily ignore errors with bumping version and pypi push"
This reverts commit cf3acec555.
2024-11-22 02:13:29 +00:00
Šarūnas Nejus
0780bf386c
Release: make sure release artefacts are present for the tagging job 2024-11-22 02:05:36 +00:00