Commit graph

12768 commits

Author SHA1 Message Date
Šarūnas Nejus
3a663ad52e
Fix musicbrainz extra tags dict (#5789)
Fixes #5788

This PR fixes a regression that occurred when the MusicBrainz autotagger
was moved from core functionality into a standalone plugin. During this
transition, the handling of user-configured `extra_tags` was broken,
causing `beets` to die with `AttributeError` when this option was set.

Key changes in `musicbrainz` plugin

- Properly process values from `extra_tags` using the same logic as
before the migration.
- Centralize common bits from `candidates` and `item_candidates`
implementations under `_search_api` to move this class closer towards
`MetadataSourcePlugin` definition.
2025-05-19 09:23:23 +01:00
Šarūnas Nejus
e8e9369bc7
Remove unused extra_tags parameter 2025-05-19 09:18:06 +01:00
Šarūnas Nejus
2ec65ed8ca
Deduplicate candidate methods using _search_api method 2025-05-18 20:09:52 +01:00
Šarūnas Nejus
0102f3ce7d
Take into account va_likely param and remove redundant checks
- Instead of checking for empty `artist` query, use `va_likely`
  parameter to determine whether we should query for Various Artists or
  not.
- `album` / `title` is always a truthy string - no need to handle empty
  criteria case
- `tracks` list always has at least one track - no need to check for
  `len(items)`
2025-05-18 20:09:52 +01:00
Šarūnas Nejus
6487893315
Synchronise docs with the actual supported extra_tags 2025-05-18 20:09:51 +01:00
Šarūnas Nejus
be74936134
Handle extra_tags the way they used to be handled 2025-05-18 20:09:50 +01:00
Martin Atukunda
ab7b7a2e29
docs(plugin/web): update changelog 2025-05-18 20:59:29 +03:00
Martin Atukunda
7c799beda8
style(plugin/web): run djlint over html to clean it up a bit 2025-05-18 20:59:29 +03:00
Martin Atukunda
992d376d1b
feat(plugin/web): add artist and album to the item entry template 2025-05-18 20:59:29 +03:00
Šarūnas Nejus
e88aa8a450
feat: plugins/web: use media session api for notifications. (#5714)
The Media Session API provides a way to customize media notifications.
This PR has commits that, in summary, updates the metadata for the media
session whenever a new track (item) starts playing.

https://developer.mozilla.org/en-US/docs/Web/API/Media_Session_API
2025-05-18 17:21:18 +01:00
Martin Atukunda
a75d2b4aa6 Update beetsplug/web/static/beets.js
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-05-18 17:16:29 +01:00
Martin Atukunda
d1d58569e1 Update beetsplug/web/static/beets.js
don't pollute global scope with album_id

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-05-18 17:16:29 +01:00
Martin Atukunda
1714705875 doc: plugin/web: now shows notifications using Media Session API 2025-05-18 17:16:29 +01:00
Martin Atukunda
b0238d934e feat: plugins/web: use media session api for notifications.
The Media Session API provides a way to customize media notifications.
This commit updates the metadata for the media session whenever a new
track (item) starts playing.

https://developer.mozilla.org/en-US/docs/Web/API/Media_Session_API
2025-05-18 17:16:29 +01:00
Šarūnas Nejus
4ddd782e8a
Centralize release id extraction (#5761)
Refactor: Centralize release ID extraction

This change introduces a new utility function `extract_release_id` in
`beets.util.id_extractors` to handle the parsing of release IDs (or URLs
containing IDs) for various metadata sources (Spotify, Deezer, Beatport,
Discogs, MusicBrainz, Bandcamp, Tidal).

Key changes:
- Added `extract_release_id` function and `PATTERN_BY_SOURCE` regex
dictionary.
- Converted `MetadataSourcePlugin._get_id` static method to an instance
method which uses the `data_source` property to pick the correct id
extractor.
- Removed the `id_regex` property and updated `_get_id` calls in all
modules.
- Replaced old tests related to ID parsing in individual plugin test
files with `test/util/test_id_extractors.py` that tests the
`extract_release_id` function.

This refactoring simplifies the codebase, reduces redundancy, and makes
it easier to manage and extend ID extraction logic for different
sources.
2025-05-18 14:43:59 +01:00
Šarūnas Nejus
8936ae4e6f
Test URL extraction against other sources 2025-05-17 14:57:34 +01:00
Šarūnas Nejus
b520981c9c
plugins: restructure id extraction 2025-05-17 14:57:34 +01:00
Šarūnas Nejus
050f8a5a5f
Importer restructure (#5624)
## Description

Hello y'all, when working on the importer.py file in a previous
[PR](#5611) I noticed that this file grew quite large and badly needs a
restructuring. Restructuring should improve our ability to apply changes
to it in the future and isolate sub-functionalities within the importer.

### Overview

For now I only changed the structure keeping the code (mostly)
unchanged.

I split the functions and classes in the importer.py into the following
responsibilities:
- `importer/session.py` : Includes the `ImportSession` class.
- `importer/stages.py` : Includes all stage functions, I prefixed the
helper functions with a `_` to allow distinguishing between stages and
helper functions more easily.
- `importer/state.py` : Includes the logic for the `ImportState`
handling i.e. the resume feat.
- `importer/tasks.py` : Includes the `ImportTask` class and all derived
classes. Also includes the `Action` enum which I have renamed from
`action`.
- `importer/__init__.py` : Identified all public facing classes and
functions and added them to `__all__`

### Potential future changes

I don't want to add this to this PR but there are some places here where
I see possible improvements for our code:
- There are quite some config parsing related functions in the
ImportSession which could be isolated (see e.g. set_config,
want_resume). Maybe a mixin class which handles the config operations
could be useful?
- The ImportSession should be abstract if it is not used directly (I
think it shouldn't). The function definitions which raise NotImplemented
errors are quite weird imo and could be avoided by making the class
abstract.
- For me it was difficult to understand the flow of the importer as
stages call session function and it is not clear which function is
called by which stage and when. Maybe a naming convention for the stage
functions in conjunction with the session methods could help here. Not
sure how this will look in practice but right now it is quite hard to
follow imo. Alternatively splitting the session into a outfacing session
and a session context which is passed to the stages could help.
- The use of the stage decorator is highly inconsistent. Maybe a better
way to handle the stages could be found. This is more of a pipeline
related issue and not directly related to the restructuring but I think
it is worth mentioning.
- Similar to the ImportSession, I think the ImportTask should be
abstract as well, maybe we can put a bit more thought into the task
hierarchy. This might also automatically improve the flow of the
importer pipeline.

Am happy to tackle some of these issues in future PRs if you also think
they are worth it.

Best,
Sebastian


Note: This PR is based on #5611 and can only be merged once the typing
additions are accepted.
2025-05-17 14:54:55 +01:00
Sebastian Mohr
7d96334924 Added function move to git ignore 2025-05-17 13:13:27 +02:00
Sebastian Mohr
a2e316d444 Merge remote-tracking branch 'upstream/master' into importer-restructure 2025-05-17 10:32:50 +02:00
Šarūnas Nejus
613c827ca3
Make musicbrainz a plugin (#5748)
# Move MusicBrainz autotagger from core to plugin

Fixes #2686
Fixes #4605

This PR relocates the MusicBrainz autotagger functionality from the
beets core into a dedicated plugin. This promotes better code
organization and follows beets' modular design approach.

Key changes:
- Move code from `beets/autotag/mb.py` to new `beetsplug/musicbrainz.py`
- Update default config to include 'musicbrainz' in the plugins list
- Refactor related plugin APIs for better integration
- Update documentation with new musicbrainz plugin page

Impact for users: If you've customized your `plugins` list in
configuration, you'll need to explicitly add `musicbrainz` to continue
using MusicBrainz for autotagging.
2025-05-17 03:40:45 +01:00
Šarūnas Nejus
f1dc75f743
Fix types in all edited files 2025-05-17 03:32:01 +01:00
Šarūnas Nejus
78462245b7
Use wraps for notify_info_yielded decorator 2025-05-17 03:32:01 +01:00
Šarūnas Nejus
3f1d117078
Add musicbrainz to plugins docs 2025-05-17 03:32:00 +01:00
Šarūnas Nejus
e981fb1aea
Deprecate musicbrainz.enabled configuration 2025-05-17 03:32:00 +01:00
Šarūnas Nejus
874fb3da7b
Add changelog note about musicbrainz 2025-05-17 03:32:00 +01:00
Šarūnas Nejus
33bed79a13
Move scrub test to a separate file 2025-05-17 03:32:00 +01:00
Šarūnas Nejus
7ff73d9747
musicbrainz: set default config in the code 2025-05-17 03:31:59 +01:00
Šarūnas Nejus
736d7d5fd0
Make musicbrainz docs follow the typical style 2025-05-17 03:31:59 +01:00
Šarūnas Nejus
df56bfeec9
Move musicbrainz docs to a separate file 2025-05-17 03:31:59 +01:00
Šarūnas Nejus
0980c82959
musicbrainz: update patches 2025-05-17 03:31:59 +01:00
Šarūnas Nejus
bef0bcbaa6
musicbrainz: synchronise plugin import path 2025-05-17 03:31:58 +01:00
Šarūnas Nejus
4fc9f0c3d6
Centralize AutotagStub test setup into AutotagImportTestCase 2025-05-17 03:31:58 +01:00
Šarūnas Nejus
5df857674c
plugins: add types and documentation to metadata backends methods and functions 2025-05-17 03:31:58 +01:00
Šarūnas Nejus
a538a3a150
musicbrainz: move handling of extra tags to musicbrainz plugin 2025-05-17 03:31:58 +01:00
Šarūnas Nejus
de0958ca65
Use candidate function from plugins instead of hooks 2025-05-17 03:31:57 +01:00
Šarūnas Nejus
2fcb48d7a4
Remove ...for_mbid methods and simplify the rest 2025-05-17 03:31:57 +01:00
Šarūnas Nejus
d8067b219b
musicbrainz: use self.config and self._log 2025-05-17 03:31:57 +01:00
Šarūnas Nejus
fd62d6a0b8
Integrate functionality with BeetsPlugin shenanigans 2025-05-17 03:31:57 +01:00
Šarūnas Nejus
529aaac7dc
Move functionality under MusicBrainzPlugin 2025-05-16 23:08:38 +01:00
Šarūnas Nejus
06dde6e37e
Define MusicBrainzPlugin 2025-05-16 20:17:59 +01:00
Šarūnas Nejus
5dc6f45110
musicbrainz: reorder methods
This will make it easier to track changes in later commits.
2025-05-16 19:56:50 +01:00
Šarūnas Nejus
e6e610a3ef
Move musicbrainz to beetsplug directory 2025-05-16 19:56:50 +01:00
snejus
d487d675b9 Increment version to 2.3.1 2025-05-14 09:53:19 +00:00
Šarūnas Nejus
69a76edc33
Pin poetry version below <2 (#5782)
Force `poetry` version below 2 to avoid it mangling file modification
times in `sdist`.

Fixes #5770
2025-05-14 10:48:00 +01:00
Šarūnas Nejus
80cf9ea888
Update pipx-install-action action version 2025-05-14 10:42:07 +01:00
Šarūnas Nejus
28781e9077
Pin Poetry version <2 2025-05-14 10:42:07 +01:00
Gavin Tronset
b92a1b3d98
Add beets-filetote to community plugins docs (#5779)
Add link to community plugin
[`beets-filetote`](https://github.com/gtronset/beets-filetote).

This plugin is the spiritual successor to
[beets-copyartifacts](https://github.com/adammillerio/beets-copyartifacts)
(`beets-copyartifacts3` was last updated 3 years ago) and
[beets-extrafiles](https://github.com/Holzhaus/beets-extrafiles) (last
updated 5 years ago).

Given the updates and changes in beets and how outdated those plugins
are, does it make sense to keep `beets-copyartifacts` in the community
plugins list?

---------

Co-authored-by: Sebastian Mohr <39738318+semohr@users.noreply.github.com>
2025-05-13 18:48:43 +02:00
Sebastian Mohr
b6045df592
Merge branch 'master' into importer-restructure 2025-05-13 13:05:46 +02:00
Sebastian Mohr
ce61ff0006 Removed pathbytes (lint error) 2025-05-13 13:05:07 +02:00