Commit Graph
538 Commits
Author SHA1 Message Date
Christopher Larson 5bc11ea736 inline: make the album/item available directly
There have been multiple requests, in the past, for the ability to use
plugin fields in inline fields. This has not previously been available.
From what I can tell, it was intentionally left unavailable due to
performance concerns.

The way the item fields are made available to the inline python code
means that all fields are looked up, whether they're actually used by
the code or not. Doing that for all computed fields would be a
performance concern.

I don't believe there's a good way to postpone the field computation, as
python eval and compile requires that globals be a dictionary, not a
mapping. Instead, we can make available the album or item model object
to the code directly, and let the code access the fields it needs via
that object, resulting in postponing the computation of the fields until
they're actually accessed.

This is a simple approach that makes the computed and plugin fields
available to inline python, which allows for more code reuse, as well as
more options for shifting logic out of templates and into python code.
The object is available as `db_obj`.

Examples:

    item_fields:
      test_file_size: db_obj.filesize

    album_fields:
      test_album_path: db_obj.path
      # If the missing plugin is enabled
      test_album_missing: db_obj.missing

Signed-off-by: Christopher Larson <kergoth@gmail.com>
2026-04-15 11:59:19 -07:00
Andrew Yang 4f3e8907c4 test(chroma): consolidate gating tests into a single class
Per @snejus review feedback on #6532: merge TestChromaWithoutMusicBrainz
and TestChromaWithMusicBrainz into a single TestChromaCandidates class
with the motivating comment moved into its docstring. Test method names
now encode the 'without' / 'with' variant.
2026-04-15 00:03:23 +01:00
Andrew Yang e446554211 chroma: address review feedback
- Use @cached_property named `mb` (per snejus/semohr) instead of a
  helper method, reducing the diff relative to the original code
- Move changelog entry to the Unreleased section (per snejus)
- Refactor tests to use PluginMixin from beets.test.helper (per
  semohr) instead of manually managing beets.plugins._instances
2026-04-15 00:03:23 +01:00
Andrew Yang 692ef4a923 chroma: gate candidates on the musicbrainz plugin being enabled
The chroma plugin uses Acoustid fingerprinting, which returns MusicBrainz
release and recording IDs. It then unconditionally resolved those IDs
through a privately instantiated MusicBrainzPlugin, so MusicBrainz-sourced
candidates appeared during tagging even when the user had not enabled the
musicbrainz plugin.

Replace the direct MusicBrainzPlugin() instantiation with a lookup through
the metadata-source registry via get_metadata_source("musicbrainz"). When
that returns None, short-circuit both candidates() and item_candidates()
to return empty. This also fixes an incidental issue where the private
instance bypassed any plugin that swaps the musicbrainz plugin at runtime
(e.g. mbpseudo).

Acoustid fingerprinting itself is unaffected — acoustid_id and
acoustid_fingerprint item fields are still populated as before.

Fixes #6212
2026-04-15 00:03:23 +01:00
Šarūnas Nejus 558b6710c1 Fix typing issues 2026-04-12 16:21:30 +01:00
Šarūnas Nejus 9394f1b223 Normalize dashes to underscores in musicbrainz data fields 2026-04-12 16:21:30 +01:00
Šarūnas Nejus fbc2986f8b Add ability to set temporary music dir context for ipfs 2026-04-11 13:02:42 +01:00
Šarūnas Nejus 9db82be003 Fix paths for Windows 2026-04-11 13:02:42 +01:00
Šarūnas Nejus e3ec808491 Use context to share music_dir 2026-04-11 13:01:41 +01:00
Sebastian Mohr 6df7dadfaf Fixed issue with differences in how mp starts processes now.
This is needed for the unitest patch decorator to work similar in python
3.14 in compassion to earlier versions.
2026-04-11 11:18:43 +01:00
J0J0 Todos e0b757ceb3 Remove unused import in lastgenre tests 2026-04-11 02:39:50 +02:00
Šarūnas Nejus 19353999ae Simplify fetch_genre 2026-04-11 02:25:02 +02:00
Šarūnas Nejus f66cc3fb57 lastgenre: use a single fetch method
Delegate the responsibility of getting relevant model fields to the
client by declaring the genre fetching spec on the class.
2026-04-11 02:25:02 +02:00
Šarūnas Nejus 2ff7887725 Apply all matching rules to a field 2026-04-10 14:54:57 +01:00
Šarūnas Nejus c9064012a1 Show that only the first pattern applied currently 2026-04-10 11:52:15 +01:00
Šarūnas Nejus c81cfebc7b Handle list fields in rewrite 2026-04-10 10:43:25 +01:00
Šarūnas Nejus bfd20b2abc Add a failing test for list fields 2026-04-10 10:37:36 +01:00
Šarūnas Nejus 9b6b7d3cd6 Add tests for rewrite plugin 2026-04-10 09:34:55 +01:00
J0J0 Todos 43e13dcfd3 lastgenre: Tests for genre ignorelist feature 2026-04-09 21:50:29 +02:00
Maxr1998 ee1a1632a0 Fix tests 2026-04-09 10:40:59 +02:00
Mathilde Gilles e49398b2f5 Merge branch 'master' into fetchart-webp 2026-04-08 16:38:02 +02:00
Alok Saboo cb8d3abe8d listenbrainz: add --max option and drop per-listen MB lookups
- Add `beet lbimport --max=N` to cap the number of listens fetched.
- Remove the MusicBrainz API lookup from get_tracks_from_listens.
  Previously, every listen without a recording_mbid in the API mapping
  triggered a live MB search, causing the import to hang for hours on
  large listen histories. Matching falls back to artist/title/album
  which is already handled by update_play_counts.
2026-04-08 08:34:48 -04:00
ShimmerGlass 3194666610 feat(fetchart): add support for webp files 2026-04-08 12:39:58 +02:00
Alok Saboo af8d716b82 address reviewer comments 2026-04-07 20:37:15 -04:00
Alok Saboo 0fe518245e lint 2026-04-07 20:36:36 -04:00
Alok Saboo 9e02536bee ListenBrainz: aggregate play counts and improve pagination logic 2026-04-07 20:31:14 -04:00
ShimmerGlass 142e946588 fix(fetchart): sources definition
The fetchart plugin would silently drop unknown sources defined in
config, leading to hard to debug problems.
The plugin now errors when an unknown source is configured, or when no
sources are configured.
In addition, a single string is now a valid value for `sources` to
either enable all sources with an `*` or a single source.

Fixes: #6336
2026-04-07 18:55:53 +02:00
Šarūnas Nejus 597d5c162a discogs: swap style and genre 2026-04-06 16:40:33 +01:00
ShimmerGlass f1a95bed57 fix(replaygain): clear conflicting tags on write
There are two ways to store replay gain data on music files: RG_ and
R128_ (opus). before this change the beets replaygain plugin simply set
the right tag based on file format and r128 config value.
there are case, however, when for example an opus files comes with RG_
tags already set. After beet write its replaingain tags the files will
contain both RG_ and R128_ tags with possibly conflicting values.
For example, Navidrome currently always prefers RG_ tags over R128_
regardless of format, leading tags set by beets to be ignored.
https://github.com/navidrome/navidrome/blob/23f3556371321faf199866989b906f2ef06a8034/model/metadata/map_mediafile.go#L111

As per RFC 7845: Ogg Encapsulation for the Opus Audio Codec
https://datatracker.ietf.org/doc/html/rfc7845#section-5.2.1
> To avoid confusion with multiple normalization schemes, an Opus
> comment header SHOULD NOT contain any of the REPLAYGAIN_TRACK_GAIN,
> REPLAYGAIN_TRACK_PEAK, REPLAYGAIN_ALBUM_GAIN, or
> REPLAYGAIN_ALBUM_PEAK tags, unless they are only to be used in some
> context where there is guaranteed to be no such confusion.

Since the replaygain plugin does not support setting both RG_ and R128_
at the same time it doesn't make much sense to keep conflicting tags
when writing. These tags are also easy to recalculate if needed either
with beets itself (with a different configuration), or by running
replaygain commands by hand. no valuable information is lost.

This change makes it so the replagain plugin now deletes conflicting
tags when processing library items:
* RG_ are deleted if we set R128_
* R128_ are deleted if we set RG_
2026-04-05 15:19:39 +02:00
Šarūnas Nejus a867b961cc Migrate arranger -> arrangers 2026-04-05 09:15:23 +01:00
Šarūnas Nejus 85eaa447f0 Migrate composer -> composers 2026-04-05 09:15:23 +01:00
Šarūnas Nejus c8360e5b11 Use __setattr__ to handle setting legacy string fields 2026-04-05 09:15:23 +01:00
ShimmerGlass 1242f42b37 feat(chroma): add chromasearch command
This command lets user search the database by chromaprint fingerprint
similarity.
Database item fingerprints are computed on the fly if needed.
This is useful for example to check if an unknown / untagged audio file
already exists in the database.
2026-04-04 15:03:42 +02:00
J0J0 Todos b32f220523 smartplaylist: Test new shell quoting behavior 2026-04-04 13:35:22 +01:00
J0J0 Todos 63b23e4a5c autobpm: Test force, quiet, overwrite fallback 2026-04-03 11:28:37 +02:00
Šarūnas Nejus db7c753ebe Update listenbrainz accordingly 2026-03-31 01:36:08 +01:00
Šarūnas Nejus d7c9e268f9 Refactor process_tracks and add tests 2026-03-31 01:36:08 +01:00
zqmfb 60d7953f99 Add test for lastgenre with existing semicolon-delimited tags 2026-03-29 08:39:45 +01:00
Šarūnas Nejus b8def07121 autotag: use explicit imports 2026-03-28 12:26:27 +00:00
Šarūnas Nejus 5fad834ad2 Ensure we use Distance to initialise Match objects 2026-03-22 19:23:53 +00:00
Šarūnas Nejus 79787cfd97 tagging: fix list albumartists field 2026-03-22 19:23:52 +00:00
kelamg 989fc665c9 Improve test 2026-03-22 01:46:50 +00:00
kelamg 2e70472748 Remove + chars 2026-03-22 01:46:50 +00:00
kelamg 2f83c0869e Fix integration test 2026-03-22 01:46:50 +00:00
kelamg b3bcb78349 Fix indentation 2026-03-22 01:46:50 +00:00
jochem 55b6fbe77d copied more generic implementation from snejus, and updated the tests and docs accordingly 2026-03-22 01:46:50 +00:00
kelamg 9a735df125 Fix formatting 2026-03-22 01:46:50 +00:00
kelamg ec4def9e91 Refactor exclusion tests to pytest 2026-03-22 01:46:50 +00:00
jochem 2f9ee89b2a Added feature to exclude albums/songs during importing when auto is enabled, as requested in issue #3523. Also added corresponding tests and documentation. 2026-03-22 01:46:50 +00:00
J0J0 Todos af8cbc179c lastgenre: Adapt test to canon helpers move 2026-03-17 06:52:30 +01:00