Commit graph

13264 commits

Author SHA1 Message Date
Henry
6aba11d4a0 testing, updated changelog 2025-09-23 11:05:48 -07:00
Henry
2bf411e77d Featured artists extracted and appended, need to see if join needs to be variable 2025-09-23 10:11:13 -07:00
Henry
84e52e1b4a Test written, beginning fix 2025-09-22 20:49:53 -07:00
Šarūnas Nejus
5e0e898429
Discogs Label Disambiguation Fix + config option. (#6035)
Fixes #5366 . 

Adds removal of disambiguation from label names, in addition this PR
moves the Discogs disambiguation function out of the
MetadataSourcePlugin, and puts it in the Discogs plugin, keeping the
parent class more generic.

A config option has been added to allow disabling Discogs disambiguation
removal. Tests and docs are written for the feature, and shows no side
effects in other plugins that rely on the MetadataSourcePlugin.
2025-09-22 21:55:47 +01:00
Šarūnas Nejus
787d9b4a40
Merge branch 'master' into discogs-disambiguation-fix 2025-09-22 21:50:34 +01:00
Henry Oberholtzer
8e644157e8 Refactor tests, adjust changelog, move config option to new features. 2025-09-22 19:47:50 +02:00
Šarūnas Nejus
a12ca093cb
feat(FtInTitle): Support tracks by artists != album artist (#5943)
I have different expectations around this [FtInTitle test
case](fcc9341360/test/plugins/test_ftintitle.py (L147-L151)),
which represents a song on an album by a **guest artist featuring a
third artist**:

```
{
    "artist": "Alice ft. Carol",
    "album_artist": "Bob",
    "feat_part": None,
},
```

If this were Alice's album, the plugin would process the track, moving
`Carol` to the `feat_part` and changing the `artist` to `Alice`. But
because it's Bob's album, nothing happens. I don't want `Alice ft.
Carol` as an artist on Bob's album any more than I want it on Alice's
though 😭

This may be a bit of a corner case but it does happen reasonably often
in the wild:

```
Album: Flying Lotus - ASH (OST) (2025)
Track 26: Kuedo feat. Miguel Atwood-Ferguson - WHAT'S WRONG PEACH?
```

More commonly, this case applies to __compilation albums which use
`Various Artists` as an albumartist__.

Processing doesn't occur on these tracks in the current implementation
because of how
[`find_feat_part()`](fcc9341360/beetsplug/ftintitle.py (L57-L82))
kicks off:

```
# Look for the album artist in the artist field. If it's not present, give up.
albumartist_split = artist.split(albumartist, 1)
if len(albumartist_split) <= 1:
    return None
```

As best I can tell, the code is setup this way to enable parsing of more
complex cases , like a song by `Hall & Oates` on an Oates album, which
is pretty clever. But giving up in cases where albumartist isn't in the
artist field seems premature when a reasonable parsing method exists
that doesn't require it.

So this PR proposes modifications to code and tests that enables
FtInTitle to process items whose artist doesn't contain the albumartist.
It seems like what someone loading a `FtInTitle` plugin would want by
default, but if that's a contentious take then I'm happy to put it
behind a config flag.

Thanks for your consideration!
2025-09-21 22:33:19 +01:00
Trey Turner
042b5d64eb test(ftintitle): fix flake, massage mypy 2025-09-21 22:27:11 +01:00
Trey Turner
6ad7c5489c test(ftintitle): parameterize tests 2025-09-21 22:27:11 +01:00
Trey Turner
f0a6059685 feat(FtInTitle): support tracks by artists != album artist 2025-09-21 22:27:11 +01:00
Šarūnas Nejus
159f43cf46
Update missing plugin configuration options and formatting details (#6025)
Missing plugin documentation was not right. The `format` option does not
work. Updated it to reflect the use of global album and item format.
2025-09-21 19:54:05 +01:00
Alok Saboo
de4494a5b1 lint 2025-09-21 19:46:31 +01:00
Alok Saboo
76c049938c Update missing plugin configuration options and formatting details 2025-09-21 19:46:31 +01:00
henry
e577df0f25
Merge branch 'master' into discogs-disambiguation-fix 2025-09-21 09:34:12 -07:00
Henry
92579b30d8 Reformat docs 2025-09-21 09:25:30 -07:00
Henry
ba46724c7f Fix changelog conflict 2025-09-21 08:07:33 -07:00
Sebastian Mohr
c991b14e7d fix test by changing patch 2025-09-21 08:04:51 -07:00
Sebastian Mohr
f4691c85e9 Added changelog and git blame ignore rev 2025-09-21 08:04:11 -07:00
Sebastian Mohr
34114fe915 New import location for art.py 2025-09-21 08:01:48 -07:00
Sebastian Mohr
3fd49a7de8 Moved arts.py file into beetsplug namespace as it is not used in core. 2025-09-21 08:01:48 -07:00
J0J0 Todos
2c1aa27385
lastgenre: Add --pretend option for previewing genre changes (#6008)
Introduce a `--pretend` option to the lastgenre plugin, allowing users
to preview genre changes without making any modifications to their
library. This feature enhances user control by showing potential changes
before they are applied.
2025-09-21 07:21:16 +02:00
J0J0 Todos
2e307b519a lastgenre: Also mock try_write in test_pretend..
and add and original genre instead empty string (clarify intention of
test / readability). Remove not really necessary assert items checks.
2025-09-21 07:07:14 +02:00
Alok Saboo
9b1537f226 Add test for --pretend option in LastGenrePlugin to skip library updates 2025-09-21 07:07:14 +02:00
Alok Saboo
c7ee0e326c Add prefix to log messages for genre fetching in LastGenrePlugin 2025-09-21 07:07:14 +02:00
Alok Saboo
0be4cecf82 Update beetsplug/lastgenre/__init__.py
Co-authored-by: Šarūnas Nejus <snejus@protonmail.com>
2025-09-21 07:07:14 +02:00
Alok Saboo
5e6dd674a9 Update beetsplug/lastgenre/__init__.py
Co-authored-by: Šarūnas Nejus <snejus@protonmail.com>
2025-09-21 07:07:14 +02:00
Alok Saboo
56e132f352 more lint 2025-09-21 07:07:14 +02:00
Alok Saboo
95b35ded4a Lint 2025-09-21 07:07:14 +02:00
Alok Saboo
84986dc42d Enhance lastgenre plugin: add item.try_write() for write operations and improve documentation clarity 2025-09-21 07:07:14 +02:00
Alok Saboo
a57ef2cb3b Add --pretend option to lastgenre plugin for previewing genre changes 2025-09-21 07:07:14 +02:00
henry
0dc774c65d
Merge branch 'master' into discogs-disambiguation-fix 2025-09-20 14:08:43 -07:00
Sebastian Mohr
dc4e4e5020
Move art.py to beetsplug._utils package to avoid polluting core namespace (#6013)
This PR moves the `art.py` module, which is only used by the plugin
architecture, to avoid polluting the main beets namespace.
2025-09-20 14:09:58 +02:00
Sebastian Mohr
73dc8f2bc7 fix test by changing patch 2025-09-20 14:04:48 +02:00
Sebastian Mohr
4ab1bb4df4 Added changelog and git blame ignore rev 2025-09-20 14:02:25 +02:00
Sebastian Mohr
a796d6d799 New import location for art.py 2025-09-20 14:01:38 +02:00
Sebastian Mohr
28aee0fde4 Moved arts.py file into beetsplug namespace as it is not used in core. 2025-09-20 14:01:38 +02:00
Henry
8a21bacd14 Add type check 2025-09-19 21:00:37 -07:00
Henry
dda265dc77 Disambiguation fix implemented & tested 2025-09-19 20:46:07 -07:00
Henry Oberholtzer
24fbc566f6 initial changes, changelog adjusted, TODO: test for various artists and update docs 2025-09-20 01:58:56 +02:00
Henry Oberholtzer
23e46315e3 Remove Discogs Disambiguation stripping from metadata_plugins 2025-09-20 01:52:53 +02:00
Šarūnas Nejus
c56cb69e32
fix: enable tracebacks for "user"/custom sqlite functions (#5383)
A bit niche but I tried setting my bareasc prefix to an empty string,
and was getting an obtuse error. This should help make clearer what is
happening when queries fail.

The exception is not properly raised up the stack in the first place
because it happens across 2 FFI boundaries: the DB query
(Python -> SQLite), and the custom DB function (SQLite -> Python).
Thus Python cannot forwarded it back to itself through SQLite, and it's
treated as an "unraisable" exception.

We could override `sys.unraisablehook` to not print anything for the
original exception, and store it in a global for the outer Python
interpreter to fetch and raise properly, but that's pretty hacky,
limited to a single DB instance and query at once, and risks swallowing
other "unraisable" exceptions.
Instead we just tell the user to look above for what Python prints.

Sample output:
```
Exception ignored in: <function unidecode_expect_ascii at 0x7f7fa20bb060>
Traceback (most recent call last):
  File "site-packages/unidecode/__init__.py", line 60, in unidecode_expect_ascii
    bytestring = string.encode('ASCII')
                 ^^^^^^^^^^^^^
AttributeError: 'bytes' object has no attribute 'encode'
Traceback (most recent call last):
  File "site-packages/beets/dbcore/db.py", line 988, in query
    cursor = self.db._connection().execute(statement, subvals)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlite3.OperationalError: user-defined function raised exception

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "site-packages/beets/__main__.py", line 9, in <module>
    sys.exit(main())
             ^^^^^^
  File "site-packages/beets/ui/__init__.py", line 1865, in main
    _raw_main(args)
  File "site-packages/beets/ui/__init__.py", line 1852, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "site-packages/beets/ui/commands.py", line 1599, in list_func
    list_items(lib, decargs(args), opts.album)
  File "site-packages/beets/ui/commands.py", line 1594, in list_items
    for item in lib.items(query):
                ^^^^^^^^^^^^^^^^
  File "site-packages/beets/library.py", line 1695, in items
    return self._fetch(Item, query, sort or self.get_default_item_sort())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/beets/library.py", line 1673, in _fetch
    return super()._fetch(model_cls, query, sort)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/beets/dbcore/db.py", line 1301, in _fetch
    rows = tx.query(sql, subvals)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/beets/dbcore/db.py", line 991, in query
    raise DBCustomFunctionError()
beets.dbcore.db.DBCustomFunctionError: beets defined custom SQLite function failed; see the other errors above for details
```
2025-09-19 21:16:38 +01:00
ThinkChaos
eb83058b13 style: remove extraneous pass statements 2025-09-19 21:11:51 +01:00
ThinkChaos
e7e22ebb3d feat: mark SQLite custom functions as deterministic to allow caching 2025-09-19 21:11:51 +01:00
ThinkChaos
b0caac871a fix: enable tracebacks for "user"/custom sqlite functions
A bit niche but I tried setting my bareasc prefix to an empty string,
and was getting an obtuse error. This should help make clearer what is
happening when queries fail.

The exception is not properly raised up the stack in the first place
because it happens across 2 FFI boundaries: the DB query
(Python -> SQLite), and the custom DB function (SQLite -> Python).
Thus Python cannot forwarded it back to itself through SQLite, and it's
treated as an "unraisable" exception.

We could override `sys.unraisablehook` to not print anything for the
original exception, and store it in a global for the outer Python
interpreter to fetch and raise properly, but that's pretty hacky,
limited to a single DB instance and query at once, and risks swallowing
other "unraisable" exceptions.
Instead we just tell the user to look above for what Python prints.

Sample output:
```
Exception ignored in: <function unidecode_expect_ascii at
0x7f7fa20bb060>
Traceback (most recent call last):
  File "site-packages/unidecode/__init__.py", line 60, in
unidecode_expect_ascii
    bytestring = string.encode('ASCII')
                 ^^^^^^^^^^^^^
AttributeError: 'bytes' object has no attribute 'encode'
Traceback (most recent call last):
  File "site-packages/beets/dbcore/db.py", line 988, in query
    cursor = self.db._connection().execute(statement, subvals)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlite3.OperationalError: user-defined function raised exception

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "site-packages/beets/__main__.py", line 9, in <module>
    sys.exit(main())
             ^^^^^^
  File "site-packages/beets/ui/__init__.py", line 1865, in main
    _raw_main(args)
  File "site-packages/beets/ui/__init__.py", line 1852, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "site-packages/beets/ui/commands.py", line 1599, in list_func
    list_items(lib, decargs(args), opts.album)
  File "site-packages/beets/ui/commands.py", line 1594, in list_items
    for item in lib.items(query):
                ^^^^^^^^^^^^^^^^
  File "site-packages/beets/library.py", line 1695, in items
    return self._fetch(Item, query, sort or
self.get_default_item_sort())

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/beets/library.py", line 1673, in _fetch
    return super()._fetch(model_cls, query, sort)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/beets/dbcore/db.py", line 1301, in _fetch
    rows = tx.query(sql, subvals)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/beets/dbcore/db.py", line 991, in query
    raise DBCustomFunctionError()
beets.dbcore.db.DBCustomFunctionError: beets defined SQLite function
failed; see the other errors above for details
```
2025-09-19 21:11:51 +01:00
Sebastian Mohr
b65d773c8e
fix incorrect matches when album is missing or empty in spotify plugin search filter (#6012)
Only include non-empty artist and album filters in Spotify track
search and metadata candidate queries to prevent incorrect matches when
the album field is missing or empty.

closes #5189
2025-09-19 17:26:52 +02:00
Sebastian Mohr
efbfc23931 Removed config options and fixed a bug with beet spotify command 2025-09-19 17:20:51 +02:00
Sebastian Mohr
c7ba399dd1 fix incorrect matches when album is missing or empty
closes #5189
2025-09-19 17:20:51 +02:00
Vrihub
0ac7fb42f5
Merge branch 'master' into ffnp 2025-09-19 12:49:22 +02:00
Sebastian Mohr
c265bd7727
fromfilename: Don't crash if title is missing (#5907)
Prevent crash if title is removed from database by black magic.
2025-09-18 15:03:56 +02:00
Rebecca Turner
a302b6d9c2 fromfilename: Don't crash if title is missing
Prevents this crash:

```
$ beet import ~/Music/Music/_/[1405]/00.mp3
Traceback (most recent call last):
  File "/nix/store/lfv9ns20hz2bg6d44js378vcxjfm9261-beets-2.3.1/bin/.beet-wrapped", line 9, in <module>
    sys.exit(main())
             ~~~~^^
  File "/nix/store/lfv9ns20hz2bg6d44js378vcxjfm9261-beets-2.3.1/lib/python3.13/site-packages/beets/ui/__init__.py", line 1859, in main
    _raw_main(args)
    ~~~~~~~~~^^^^^^
  File "/nix/store/lfv9ns20hz2bg6d44js378vcxjfm9261-beets-2.3.1/lib/python3.13/site-packages/beets/ui/__init__.py", line 1838, in _raw_main
    subcommand.func(lib, suboptions, subargs)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/lfv9ns20hz2bg6d44js378vcxjfm9261-beets-2.3.1/lib/python3.13/site-packages/beets/ui/commands.py", line 1390, in import_func
    import_files(lib, byte_paths, query)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/lfv9ns20hz2bg6d44js378vcxjfm9261-beets-2.3.1/lib/python3.13/site-packages/beets/ui/commands.py", line 1330, in import_files
    session.run()
    ~~~~~~~~~~~^^
  File "/nix/store/lfv9ns20hz2bg6d44js378vcxjfm9261-beets-2.3.1/lib/python3.13/site-packages/beets/importer/session.py", line 234, in run
    pl.run_parallel(QUEUE_SIZE)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/nix/store/lfv9ns20hz2bg6d44js378vcxjfm9261-beets-2.3.1/lib/python3.13/site-packages/beets/util/pipeline.py", line 471, in run_parallel
    raise exc_info[1].with_traceback(exc_info[2])
  File "/nix/store/lfv9ns20hz2bg6d44js378vcxjfm9261-beets-2.3.1/lib/python3.13/site-packages/beets/util/pipeline.py", line 336, in run
    out = self.coro.send(msg)
  File "/nix/store/lfv9ns20hz2bg6d44js378vcxjfm9261-beets-2.3.1/lib/python3.13/site-packages/beets/util/pipeline.py", line 219, in coro
    func(*(args + (task,)))
    ~~~~^^^^^^^^^^^^^^^^^^^
  File "/nix/store/lfv9ns20hz2bg6d44js378vcxjfm9261-beets-2.3.1/lib/python3.13/site-packages/beets/importer/stages.py", line 141, in lookup_candidates
    plugins.send("import_task_start", session=session, task=task)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/lfv9ns20hz2bg6d44js378vcxjfm9261-beets-2.3.1/lib/python3.13/site-packages/beets/plugins.py", line 505, in send
    result = handler(**arguments)
  File "/nix/store/lfv9ns20hz2bg6d44js378vcxjfm9261-beets-2.3.1/lib/python3.13/site-packages/beets/plugins.py", line 200, in wrapper
    return func(*args, **kwargs)
  File "/nix/store/lfv9ns20hz2bg6d44js378vcxjfm9261-beets-2.3.1/lib/python3.13/site-packages/beetsplug/fromfilename.py", line 165, in filename_task
    apply_matches(d, self._log)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/nix/store/lfv9ns20hz2bg6d44js378vcxjfm9261-beets-2.3.1/lib/python3.13/site-packages/beetsplug/fromfilename.py", line 124, in apply_matches
    item.title = str(d[item][title_field])
                     ~~~~~~~^^^^^^^^^^^^^
KeyError: 'title'
```
2025-09-18 14:57:48 +02:00