Commit graph

13232 commits

Author SHA1 Message Date
asardaes
be0b71043c Revert "Remove class variables for template fields and funcs"
This reverts commit a7033fe63b.
2025-11-21 18:31:59 +01:00
asardaes
23a19e9409 Remove class variables for template fields and funcs 2025-11-21 18:31:59 +01:00
asardaes
2eff2d25f5 Improve typing for template fields and funcs 2025-11-21 18:31:59 +01:00
asardaes
9c37f94171 Add album template value in ftintitle plugin 2025-11-21 18:31:59 +01:00
Sebastian Mohr
f79c125d15
Catch ValueError when beetsplug.bpd cannot be imported (#6170)
Catch ValueError when setting gst required version

`pytest.importorskip` is used to catch the case when beetsplug.bpd cannot
be imported. On macOS, the `gi` module was able to be imported, but when
trying to specify `gi.require_version`, a `ValueError` is raised about
Gst being unavailable. pytest does not catch this `ValueError` during
`importskip` as it is not an `ImportError`, and thus the test suite
errors during the test collection phase.

With this change, we catch the ValueError, and re-raise it as an
`ImportError` and pytest gracefully skips those tests.

Fixes #3324
2025-11-19 12:49:07 +01:00
Ognyan Moore
aa2dc9005f
Catch ValueError when setting gst required version
pytest.importskip is used to catch the case when beetsplug.bpd cannot be
imported. On macOS, the gi module was able to be imported, but when
trying to specify `gi.require_version`, a ValueError is raised about
Gst being unavailable. pytest does not catch this ValueError during
importskip as it is not an ImportError, and thus the test suite errors
during the test collection phase.

With this change, we catch the ValueError, and re-raise it as an
ImportError and pytest gracefully skips those tests.
2025-11-19 14:43:30 +03:00
Sebastian Mohr
88ca0ce1fb
Plugins/web: fix endpoints /…/values/… (#6158)
Following #4709 and #5447, the web plugin used single-quotes (ie. string
litteral) in the SQL query for table columns.

Thus, for instance, the query `GET /item/values/albumartist` would
return the litteral "albumartist" instead of a list of unique album
artists.

This prevents the Mopidy beets integration from working, returning the
single artist "albumartist".
2025-11-17 10:21:31 +01:00
Théophile Bastian
189fedb008 Web plugin: add type hint for g.lib 2025-11-15 21:02:43 +01:00
Théophile Bastian
666c412b0e plugins/web: fix endpoints /…/values/…
Following #4709 and #5447, the web plugin used single-quotes (ie. string
litteral) in the SQL query for table columns. Thus, for instance, the query
`GET /item/values/albumartist` would return the litteral "albumartist"
instead of a list of unique album artists.
2025-11-15 21:02:38 +01:00
Sebastian Mohr
07445fdd07
Fix import --from-logfile (#6161)
Fixes "none of the paths are importable" error that was accidentally
introduced in 4260162d4

4260162d44 (diff-e324b20657a7d6b43b8b7aeb5754b96774f5062294b5ba7f1e3062845e9e7044R1382-R1390)
2025-11-13 19:32:19 +01:00
J0J0 Todos
97bc0b3b8c Changelog for #6161 2025-11-13 19:26:18 +01:00
J0J0 Todos
2ef77852b7 Fix import --from-logfile
Fixes "none of the paths are importable" error with any valid import log
file that was accidentally introduced in commit 4260162d4
2025-11-13 19:26:18 +01:00
Šarūnas Nejus
e326aafac0
Allow selecting either tags or genres in the includes, defaulting to genres (#5874)
Genres is a filtered list based on what musicbrainz considers a genre,
tags are all the user-submitted tags. [1]

1.
https://musicbrainz.org/doc/MusicBrainz_API#:~:text=Since%20genres%20are,!).
2025-11-12 21:40:02 +00:00
Aidan Epstein
672bf0bf41 Add tests. 2025-11-11 17:08:46 -08:00
Aidan Epstein
d7636fb0c3 Apply suggestions from code review
Co-authored-by: Šarūnas Nejus <snejus@protonmail.com>
2025-11-11 13:18:51 -08:00
Aidan Epstein
9e7d5debdc Allow selecting either tags or genres in the includes, defaulting to genres
Genres is a filtered list based on what musicbrainz considers a genre,
tags are all the user-submitted tags. [1]

1. https://musicbrainz.org/doc/MusicBrainz_API#:~:text=Since%20genres%20are,!).

Also apply suggestions from code review

Co-authored-by: Šarūnas Nejus <snejus@protonmail.com>
2025-11-11 20:01:37 +00:00
Sebastian Mohr
f3da80e512
FIX: Dereference symlinks before hardlinking (#5684)
When creating a hardlink, either during import or `beet convert`, if the
origin of the hardlink was a symlink, that symlink used to be directly
copied. This could create broken symlinks if the origin symlink was
relative, and in either case, probably wasn't the user's desired
behavior.

This change de-references all symlinks before creating a hardlink, such
that the end result is a normal file with the same inode as the original
file. See #5676 for more discussion about the original issue.

Fixes #5676
2025-11-11 17:07:47 +01:00
Emi Katagiri-Simpson
29a5b06f67
Merge remote-tracking branch 'upstream/master' into dereference-symlinks-while-hardlinking 2025-11-11 07:58:10 -05:00
Šarūnas Nejus
3a72d85c5e
Drop support for Python 3.9 (#6144)
Drop support for Python 3.9 and pyupgrade the codebase.

Dependency upgrades:

<img width="644" height="1017" alt="image"
src="https://github.com/user-attachments/assets/e5be110b-66fb-4373-8413-e09a56ba54bc"
/>
2025-11-11 04:09:46 +00:00
Šarūnas Nejus
bef249e616
Fix format-docs command 2025-11-11 04:03:52 +00:00
Šarūnas Nejus
881549e83c
Enable all pyupgrade lint rules 2025-11-08 12:09:52 +00:00
Šarūnas Nejus
ffa70acad9
Ignore pyupgrade blame 2025-11-08 12:09:52 +00:00
Šarūnas Nejus
d486885af3
pyupgrade Python 3.10 2025-11-08 12:09:52 +00:00
Šarūnas Nejus
dc33932871
Update python version references 2025-11-08 12:09:52 +00:00
Šarūnas Nejus
a7830bebae
Update python requirement and dependencies 2025-11-08 11:55:20 +00:00
Šarūnas Nejus
d64efbb6c1
Upgrade deps before upgrade 2025-11-08 11:55:20 +00:00
Emi Katagiri-Simpson
b405d2fded
Migrate os calls to pathlib calls in hardlink util function
See discussion here: https://github.com/beetbox/beets/pull/5684#discussion_r2502432781
2025-11-07 15:05:56 -05:00
henry
29b9958626
BUG: Wrong path edited when running config -e (#5685)
As per #5652, `beet --config <path> config -e` edited the default config
path, even though that's not the config that would be used by beets.

It seems like this was the result of a deliberate short-circuit in
[`_raw_main()`](c2de6feada/beets/ui/__init__.py (L1832)).
The short-circuit prevents malformed configs from causing a crash before
opening the editor, but also prevents the setup function from loading
the custom config at all.

The solution used here is to just expose the CLI options to
`edit_config()`, so that it can use the custom config path if its set. I
also suspect that the branch in
[`config_func()`](c2de6feada/beets/ui/commands.py (L2354))
which is getting short circuited is actually unreachable, but I left it
in with a note just in case.

Fixes #5652

## To Do

- [x] ~~Documentation~~ (N/A)
- [X] Changelog
- [X] Tests
2025-11-07 11:51:26 -08:00
henry
81f10729e1
Merge branch 'master' into edit-custom-config 2025-11-07 11:40:50 -08:00
Sebastian Mohr
7cca07d2c3
Accept lyrics source as a string (#6149)
## Description

Fixes #5962.

The fix was shared in the issue. Now it uses ```as_str_seq``` similarly
to other plugins.
2025-11-07 10:40:35 +01:00
Ratiq Narwal
26a8e164d5 Remove newline character between list points 2025-11-06 18:10:48 -08:00
Ratiq Narwal
f77c03ed90 Remove unnecessary space 2025-11-06 17:58:25 -08:00
Ratiq Narwal
60ad6dc503 Fix changelog formatting 2025-11-06 17:41:21 -08:00
Emi Katagiri-Simpson
0e74605efd
Merge remote-tracking branch 'upstream/master' into dereference-symlinks-while-hardlinking 2025-11-06 20:30:40 -05:00
Ratiq Narwal
a7becf8490 Improve changelog 2025-11-06 17:29:33 -08:00
Ratiq Narwal
e9afe069bc Accept lyrics source as a string 2025-11-06 17:19:27 -08:00
Emi Katagiri-Simpson
86a74970f9
Merge remote-tracking branch 'upstream/master' into HEAD 2025-11-06 20:11:57 -05:00
Sebastian Mohr
61a4c737ee
Refactor ui/commands.py monolith into modular structure (#6119)
## Description

This one’s a big one 🎣 Proceed with care and a bit
of time ;)

The `ui/commands.py` file had grown into an unwieldy monolith (2000+
lines) over time, so this PR breaks it apart into a modular structure
i.e. **one file per command**, plus some cleanup and reorganization
along the way.

---

###  What changed

* **Commands modularized:**
Every command (`help`, `list`, `move`, `update`, `remove`, etc.) now
lives in its own file under `ui/commands/`.
* **Support code reorganized:**
  * Utility functions moved into a separate helper module.
* `commands.py` converted into `commands/__init__.py` for better import
handling.
* The `import` command (and related helpers) moved into its own folder:
    * `importer/session.py` for import session logic
    * `importer/display.py` for display-related functions
* **Tests cleaned up:**
  * Each command’s tests now live in their own file.
  * All UI-related tests were moved into a dedicated folder for clarity.
2025-11-05 16:01:10 +01:00
Sebastian Mohr
f495a9e18d Added more descriptions to git-blame-ignore-revs file. 2025-11-05 15:54:35 +01:00
Sebastian Mohr
b3b7dc3316 Added changelog entry and git blame ignore revs. 2025-11-03 14:04:58 +01:00
Sebastian Mohr
25ae330044 refactor: moved some more imports that are only used in the commands
in their respective files. Also fixed some imports
2025-11-03 14:03:25 +01:00
Sebastian Mohr
a59e41a883 tests: move command tests into dedicated files
Moved tests related to ui into own folder.
Moved 'modify' command tests into own file.
Moved 'write' command tests into own file.
Moved 'fields' command tests into own file.
Moved 'do_query' test into own file.
Moved 'list' command tests into own file.
Moved 'remove' command tests into own file.
Moved 'move' command tests into own file.
Moved 'update' command tests into own file.
Moved 'show_change' test into test_import file.
Moved 'summarize_items' test into test_import file.
Moved 'completion' command test into own file.
2025-11-03 14:00:58 +01:00
Sebastian Mohr
59c93e7013 refactor: reorganize command modules and utils
Moved commands.py into commands/__init__.py for easier refactoring.
Moved `version` command into its own file.
Moved `help` command into its own file.
Moved `stats` command into its own file.
Moved `list` command into its own file.
Moved `config` command into its own file.
Moved `completion` command into its own file.
Moved utility functions into own file.
Moved `move` command into its own file.
Moved `fields` command into its own file.
Moved `update` command into its own file.
Moved `remove` command into its own file.
Moved `modify` command into its own file.
Moved `write` command into its own file.
Moved `import` command into its own folder, more commit following.
Moved ImportSession related functions into `importer/session.py`.
Moved import display display related functions into `importer/display.py`
Renamed import to import_ as a module cant be named import.
Fixed imports in init file.
2025-11-03 13:32:14 +01:00
Sebastian Mohr
beda6fc71b
Add mbpseudo plugin for pseudo-release proposals (#5888)
## Description
Adds the new `mbpseudo` plugin, that proactively searches for pseudo-releases during import and
adds them as candidates. Since it also depends on MusicBrainz, there are
some special considerations for the default logic (which is now a plugin
as well). However, at the very least it expects a list of desired [names
of scripts](https://en.wikipedia.org/wiki/ISO_15924) in the
configuration, for example:

```yaml
mbpseudo:
    scripts:
    - Latn
```

It will use that to search for pseudo-releases that match some of the
desired scripts, but will only do so if the input tracks match against
an official release that is not in one of the desired scripts.

## Standalone Usage

This would be the recommended approach, which involves disabling the
`musicbrainz` plugin. The `mbpseudo` plugin will manually delegate the
initial search to it. Since the data source of official releases will
still match MusicBrainz, weights are still relevant:

```yaml
mbpseudo:
    source_weight: 0.0
    scripts:
    - Latn

musicbrainz:
    source_weight: 0.1
```

A setup like that would ensure that the pseudo-releases have slightly
more preference when choosing the final proposal.

## Combined Usage

I initially thought it would be important to coexist with the
`musicbrainz` plugin when it's enabled, and reuse as much of its data as
possible to avoid redundant calls to the MusicBrainz API. I have the
impression this is not really important in the end, and maybe things
could be simplified if we decide that both plugins shouldn't coexist.

As it is right now, using both plugins at the same time would still
work, but it'll only avoid redundancy if `musicbrainz` emits its
candidates before `mbpseudo`, ~which is why I modified the
plugin-loading logic slightly to guarantee ordering. I'm not sure if you
think this could be an issue, but I think the `musicbrainz` plugin is
also used by other plugins and I can imagine it's good to guarantee the
order that is declared in the configuration?~

If the above is fulfilled, the `mbpseudo` plugin will use listeners to
intercept data emitted by the `musicbrainz` plugin and check if any of
them have pseudo-releases that might be desirable.
2025-11-03 13:10:10 +01:00
asardaes
c087851770 Prefer alias if import languages not defined 2025-11-01 13:52:14 +01:00
asardaes
040b2dd940 Add custom_tags_only mode for mbpseudo plugin 2025-11-01 13:52:14 +01:00
asardaes
cb758988ed Fix data source penalty for mbpseudo 2025-11-01 13:52:14 +01:00
asardaes
defc602310 Update docs for mbpseudo plugin 2025-11-01 13:52:11 +01:00
asardaes
160297b086 Add tests for mbpseudo plugin 2025-11-01 13:51:34 +01:00
asardaes
229651dcad Update mbpseudo implementation for beets 2.5 2025-11-01 13:51:34 +01:00