Commit Graph
15300 Commits
Author SHA1 Message Date
Šarūnas Nejus 8e5dfd2eef fix(tidal): adapt to current search API (#6990)
## Problem

TIDAL album and track searches fail with HTTP 400 even after successful
authentication.

The plugin currently sends search queries as part of the URL path:

```text
GET /v2/searchResults/{query}
```

TIDAL’s current API requires the query through the `filter[query]`
parameter:

```text
GET /v2/searchResults?filter[query]={query}
```

The response format has also changed: `data` is now an array containing
the search-results resource rather than the resource object itself.

Fixes #6989.

## Fix

- Send search requests to `/v2/searchResults`.
- Pass the query using the required `filter[query]` parameter.
- Update the `SearchDocument` type for the new `data` array.
- Parse album and track relationships from the first search-results
resource.
- Handle empty search responses without raising an exception.
- Add regression coverage using a query that previously produced HTTP
400.
2026-09-05 00:25:35 +01:00
Šarūnas Nejus 5002bb8624 Merge branch 'master' into fix/tidal-search-api 2026-09-05 00:15:32 +01:00
Šarūnas Nejus f36d365a04 fix(scrub): skip scrubbing when --nowrite is passed (#6979)
When `beet import -W` (`--nowrite`) is run with the scrub plugin enabled
(`auto=True`), the plugin was scrubbing (removing) tags even though
`--nowrite` means "don't write to files". This caused tags to be lost.

The fix adds a guard at the start of `import_task_files` to skip the
entire scrub operation when `should_write()` returns `False`, making the
scrub plugin respect the `--nowrite` flag like other plugins do.

## Fixes

Fixes #6958

## Changes

- `beetsplug/scrub.py`: Add guard in `import_task_files` to skip
scrubbing when `should_write()` returns `False`
- `test/plugins/test_scrub.py`: Update test to expect tags to remain
unchanged when `--nowrite` is passed (rename `test_tags_not_restored` to
`test_tags_not_scrubbed_when_nowrite`)

## Behavior Change

Before: `beet import -W` with scrub plugin would remove all tags from
imported files
After: `beet import -W` with scrub plugin will not modify files at all,
respecting `--nowrite`
2026-09-05 00:14:39 +01:00
Šarūnas Nejus b9fbc51b62 Merge branch 'master' into fix-scrub-nowrite 2026-09-05 00:05:38 +01:00
Šarūnas Nejus 91dbec1e37 plexupdate: Add interactive plex.tv authentication and general plugin rewrite (#6978)
Rewrite the `plexupdate` plugin around Plex's PIN authentication flow.
`beet plexupdate --auth` opens a browser, authenticates with Plex, and
stores the token and generated client identifier in `plex_token.json`
next to the beets configuration.

* Add `PlexSession` for token persistence, PIN polling, and
authenticated server requests.
* Use Plex's JSON API to find the music library section.
* Refresh the library once after modifying commands.
* Clearly report missing sections and `401` responses.
* Deprecate the manual `token` option in favor of interactive
authentication.
* Update documentation, tests, and changelog.

### Motivation

`plexupdate` could easily break after Plex deployments or instances were
updated, and manually obtaining a token isn't particularly
straightforward... This rewrite makes recovery simple: if authentication
breaks, users can just run the documented `beet plexupdate --auth`
command.
2026-09-04 23:25:47 +01:00
Trey Turner 31b0a226f8 fix(tidal): adapt to current search API
Fixes #6989
2026-09-04 19:53:59 +00:00
dajiaohuang fd93aa8648 docs: wrap changelog lines for formatter 2026-09-04 14:39:58 +08:00
Sebastian Mohr 8859bb716b Small rework on the polling logic 2026-09-03 16:37:00 +02:00
Sebastian Mohr efec4bcee6 Suppress more errors during token loading to catch corrupted files. 2026-09-03 16:37:00 +02:00
Sebastian Mohr ad2665c595 Update docs and changelog
Rewrite the plugin documentation in the current style with dedicated
sections on authentication, usage, and configuration, and mark the
manual `token` option as deprecated. Add a changelog entry for the
new `beet plexupdate --auth` command.
2026-09-03 16:37:00 +02:00
Sebastian Mohr 8a2e4bb461 Add tests for the session and API layers
Cover the plex.tv PIN authentication flow, token persistence, and
the library refresh requests with mocked HTTP responses.
2026-09-03 16:37:00 +02:00
Sebastian Mohr ad51786d10 Add interactive plex.tv authentication
Rewrite the plugin around Plex' PIN authentication flow: running
`beet plexupdate --auth` opens a browser window and stores the
obtained token together with a generated client identifier in a
token file (`plex_token.json`) next to the beets configuration.

- add a PlexSession (based on TimeoutAndRetrySession) that handles
  token persistence, plex.tv PIN polling, and attaching the token to
  local server requests
- look up the music library section through the JSON API instead of
  parsing XML
- refresh the Plex library once, at the end of commands that changed
  the library; report missing sections and 401 responses clearly
  instead of failing silently
- deprecate the manual `token` configuration option in favor of the
  interactive login
2026-09-03 16:37:00 +02:00
Šarūnas Nejus 63b69fa906 Extend labeler with beets commands (#6955)
- Extends `.github/labeler.yaml` so the labeler can match not just
plugin names, but also plugin-specific command names and `beet ...` CLI
usage.
- Adds a new command-focused section for core commands like `config`,
`import`, `list`, `modify`, `update`, and others, giving them dedicated
labels.
- Architecturally, this keeps labeling logic centralized in one config
file while broadening the patterns that map PRs to labels.
- High-level impact: PRs that touch command docs, examples, or behavior
should now be labeled more accurately, which improves triage and makes
reviews easier to route.
2026-09-03 15:29:03 +01:00
Šarūnas Nejus 8a6fb4e6b9 Add commands to labeler config 2026-09-03 15:19:09 +01:00
Šarūnas Nejus 34ea382736 release: sync project version in uv.lock (#6986)
- Small release-pipeline change: after `poe bump`, the workflow now also
runs `uv lock`. Grug see this as keeping version bump and lockfile sync
in one release step, instead of splitting responsibility.

- High-level impact: release commits now update the editable project
entry in `uv.lock` as well as the main project version. In this PR,
`beets` moves from `2.13.0` to `2.13.1` inside `uv.lock`.

- Reviewer takeaway: no app runtime behavior change. This is
release-process hardening to prevent version drift between the project
metadata and `uv.lock`.
2026-09-03 15:09:49 +01:00
Šarūnas Nejus 91c3b2ab88 release: sync project version in uv.lock 2026-09-03 14:49:36 +01:00
shuwen.wu 37d5e05ecf docs: add changelog entry for scrub --nowrite fix
Add changelog entry per reviewer feedback (snejus).
2026-09-03 11:49:12 +08:00
Sebastian Mohr 8694a03f1a fix(tidal): Pass track duration as length for matching (#6982)
Closes #6966

Tidal candidates now contribute track-length distance: the converted ISO
8601 duration is passed as `TrackInfo.length` instead of being stored as
a `duration` flex attribute.

- [x] Changelog. 
- [x] Tests.
2026-09-02 22:21:46 +02:00
Sebastian Mohr deedd5c608 Pass track duration as length for matching
TrackInfo expects the converted ISO 8601 duration in its length
field. The plugin passed it as duration instead, which TrackInfo
silently stores as a flexible attribute while length stays None, so
Tidal candidates were matched without any track-length distance.

Pass the duration as length and update the parsing tests to assert
info.length instead of the incorrect info.duration flex field.
2026-09-02 21:57:24 +02:00
Šarūnas Nejus 7a9bd56872 edit: Keep rejected album fields visible per track (#6959)
Fixes #6953 

During interactive import, item-only fields configured in both
`albumfields` and `itemfields` were removed from the album header and
per-track documents.

Track fields are now excluded only when they are actually displayed in
the album header. Added a regression test for the `edit Candidates`
flow.

cc: @snejus
2026-09-02 20:55:53 +01:00
shuwen.wu 15637ed148 fix(scrub): skip scrubbing when --nowrite is passed
When `beet import -W` (--nowrite) is run with the scrub plugin
enabled (auto=True), the plugin was scrubbing (removing) tags even
though --nowrite means "don't write to files". This caused tags
to be lost.

The fix adds a guard at the start of import_task_files to skip
the entire scrub operation when should_write() returns False,
making the scrub plugin respect the --nowrite flag like other
plugins do.

Fixes #6958
2026-09-03 02:46:03 +08:00
Alok Saboo e1f3ad5d85 lint 2026-09-02 10:57:44 -04:00
Alok Saboo df8236e354 edit: allow item-only fields to remain in per-track documents during interactive import 2026-09-02 10:57:44 -04:00
Šarūnas Nejus a750105a6d Remove the dead args self-assignment in the web command (#6977)
## Description

The `web` command handler opens with `args = args`, which rebinds the
parameter to itself and does nothing. Nothing is missing behind it
either: `args` is already the third parameter of `func` and the two
`args.pop(0)` calls under it read the same list.

Going by the way beets used to receive command arguments, this reads
like a leftover from when the callback had to pull them out of somewhere
else.

## To Do

- [x] ~Documentation~ (removing a dead statement, nothing to describe)
- [x] ~Changelog~ (no user-visible change)
- [x] ~Tests~ (no behaviour to pin)
2026-09-02 10:42:42 +01:00
Dmitry Rantovov 029a9bb877 Remove the dead args self-assignment in the web command 2026-09-02 07:43:59 +03:00
J0J0 Todos fe7ff0d595 importsource: Only register listener if configured (#6297)
## Description

If the feature is not enabled, registering a listener is not required.

Added 2 new tests that prove this is the case.
2026-09-01 11:32:52 +00:00
Šarūnas Nejus e7720ce362 docs: fix two dead external links (#6950)
## Summary

A live sweep of external URLs in `docs/` found two dead links. This PR
fixes them:

| File | Dead URL | Replacement |
|------|----------|-------------|
| `docs/plugins/autobpm.rst` |
`https://librosa.org/doc/latest/generated/librosa.beat.beat_track.html`
(404) |
`https://librosa.org/doc/latest/api/generated/librosa.beat.beat_track.html`
(200) |
| `docs/plugins/chroma.rst` |
`https://developer.apple.com/technologies/mac/audio-and-video.html`
(404) | `https://developer.apple.com/documentation/coreaudio` (200) |

The ID3v2.4 URL in `docs/faq.rst` remains unchanged after review
confirmed that it is accessible.

All replacement URLs were verified HTTP 200 before this PR. Other unique
external URLs in `docs/` were checked as part of the sweep; remaining
non-2xx results were example placeholders, localhost examples, or hosts
that still exist but reject automated requests.
2026-09-01 11:52:56 +01:00
Šarūnas Nejus ca5cf8c1c8 Merge branch 'master' into docs/fix-dead-links 2026-09-01 11:26:42 +01:00
Šarūnas Nejus 6c82b43494 Typing follow up fixes (#6965)
Two small follow up fixes after merging all typing changes:

1. Removed incorrect/outdated comment in `advancedrewrite`.
2. Included commits from the last PR to `.git-blame-ignore-revs`.
2026-09-01 11:17:02 +01:00
Šarūnas Nejus 0e14dce718 Merge branch 'master' into typing-follow-up 2026-09-01 11:07:26 +01:00
Šarūnas Nejus 123ce82fc2 fetchart: Fix downloading pre-sized thumbnails from CAA (#6870)
## Description

Fixes issue in which thumbnails were rescaled locally instead of
downloading pre-sized ones from CAA.

From the
[docs](https://beets.readthedocs.io/en/stable/plugins/fetchart.html#cover-art-archive-pre-sized-thumbnails):

>The CAA provides pre-sized thumbnails of width 250, 500, and 1200
pixels. If you set the maxwidth option to one of these values, the
corresponding image will be downloaded, saving beets the need to scale
down the image. It can also speed up the downloading process, as some
cover arts can sometimes be very large.

I noticed that the fetchart plugin didn't download the pre-sized
thumbnails from CAA for some of my releases because the API didn't
provide them under the keys "500" and "250" but instead "large" and
"small". These are [legacy
keys](https://musicbrainz.org/doc/Cover_Art_Archive/API) but for some
releases they're the only ones available so I wrote this fix to use them
as a fallback.

#### Example
```sh
curl -sL "https://coverartarchive.org/release/d51434bc-fcb6-4fc0-864f-e1ab13a51de2" | jq
```
```json
{
  "images": [
    {
      "types": [
        "Front"
      ],
      "front": true,
      "back": false,
      "edit": 30140717,
      "image": "http://coverartarchive.org/release/d51434bc-fcb6-4fc0-864f-e1ab13a51de2/8891190287.png",
      "comment": "",
      "approved": true,
      "id": "8891190287",
      "thumbnails": {
        "large": "http://coverartarchive.org/release/d51434bc-fcb6-4fc0-864f-e1ab13a51de2/8891190287-500.jpg",
        "small": "http://coverartarchive.org/release/d51434bc-fcb6-4fc0-864f-e1ab13a51de2/8891190287-250.jpg"
      }
    }
  ],
  "release": "http://musicbrainz.org/release/d51434bc-fcb6-4fc0-864f-e1ab13a51de2"
}
```
2026-09-01 11:00:29 +01:00
Šarūnas Nejus e4256b5232 Fix chroma original_year type 2026-09-01 10:55:55 +01:00
Šarūnas Nejus cfe1a52f41 Remove incorrect comment 2026-09-01 10:55:55 +01:00
Šarūnas Nejus d5300af4c1 Add commits from the previous PR to git blame ignore 2026-09-01 10:55:55 +01:00
Šarūnas Nejus 3e90e2168e Merge branch 'master' into docs/fix-dead-links 2026-09-01 10:50:09 +01:00
Šarūnas Nejus 388689d911 Merge branch 'master' into master 2026-09-01 09:30:49 +01:00
Šarūnas Nejus 39ff8cccc9 Have convert use the new format when deciding path (#6105)
By overriding the format attribute of the item, beets comes up with a
destination path that the user expects.

## Description

Fixes #1360

Currently when doing a convert command, when beets determines what the
new file path should be, it uses the path to the original file, and
changes the extension, but the new format is not referenced at all when
determining the new destination path. This PR overrides the format
attribute of the item just before the destination path is resolved, thus
returning the path that takes the new format in mind.

## To Do

This is my first contribution to`beets` (and frankly, the first time
I've had reason to look at the codebase). There could very well be a
relevant class method I missed to better accomplish what I want rather
than overriding the `format` attribute
2026-09-01 09:20:03 +01:00
Šarūnas Nejus 345e839314 Merge branch 'master' into have-convert-plugin-use-new-format-in-pathing 2026-09-01 09:08:17 +01:00
Šarūnas Nejus e9a51399d9 typing: type the rest of plugins (#6940)
Fixes #6924.

- Enables repo-wide annotation checks in `pyproject.toml` via `ruff`'s
`flake8-annotations` rules, with practical carve-outs for `test/**`,
`docs/conf.py`, `Any`, and noisy variadic args. This adds a clear
enforcement layer without forcing annotations in low-value areas.

- Finishes typing the entire codebase, including command entrypoints,
import hooks, config-driven code, helper utilities, and
library/model-facing APIs. Architecturally, plugin boundaries now
describe their inputs and outputs explicitly instead of relying on
implicit contracts.

- Includes a small set of follow-on fixes uncovered by typing, mainly
around bytes vs. strings, optional values, and collection shapes. These
are mostly correctness and consistency fixes rather than intentional
behavior changes.

- Overall impact: this completes typing coverage for the full codebase.
The result is stronger static guarantees, clearer extension points, and
safer future refactors across both core and plugin code.
2026-08-31 23:07:43 +01:00
Šarūnas Nejus 95a300130b typing: relax FieldTFuncs output type 2026-08-31 11:27:12 +01:00
Šarūnas Nejus 4e9677dfa3 play: test play on import 2026-08-31 11:27:12 +01:00
Šarūnas Nejus 5c3695da26 typing: various consistency fixes 2026-08-31 11:27:12 +01:00
Šarūnas Nejus 2a45e99b63 typing: configure flake8-annotations 2026-08-31 11:27:12 +01:00
Šarūnas Nejus 0b5a5b0350 typing: fix missing types in plugins 2026-08-31 11:27:12 +01:00
Šarūnas Nejus 11d41aee7d typing: add missing types to plugins 2026-08-31 11:27:12 +01:00
Šarūnas Nejus 12c9f4233f typing: type and refactor duplicates plugin (#6947)
Part of #6924.

### What changed

- Types added to `beetsplug/duplicates.py`.
- Refactors `beetsplug/duplicates.py` so album and item commands now
share one execution path through `_run_command()`.
- Replaces the old generic `_merge()` dispatch with an explicit
`merge_func` passed into `_duplicates()`, so album and item merge
behavior stays separate but simpler.
- Tightens typing across the plugin by using clearer `Album`, `Item`,
`AlbumOrItem`, and `LibModel` annotations in the main helper methods.

### Why it matters

- The plugin's architecture is now more direct: command setup decides
`'albums'` vs `'items'`, and the shared duplicate-processing flow
handles the rest.
- This removes branching and type ambiguity from the core duplicate
logic, which makes the code easier to follow and safer to change.
- Functional behavior stays the same at a high level, but the plugin is
now easier to maintain, reason about, and extend.
2026-08-31 11:26:48 +01:00
Šarūnas Nejus 6dbb4ce756 typing: fix types and refactor duplicates plugin 2026-08-31 11:19:31 +01:00
Šarūnas Nejus 4a99a991cb Add commits to git blame ignore 2026-08-31 11:19:27 +01:00
Šarūnas Nejus 8e4fa56acb typing: add types to duplicates plugin 2026-08-31 11:01:12 +01:00
Šarūnas Nejus 301677ad00 typing: type mpdstats, thumbnails plugins (#6939)
Part of #6924.

- This PR is a typing and interface cleanup for `beetsplug/mpdstats.py`
and `beetsplug/thumbnails.py`. It does not add new features; it makes
the code's internal contracts clearer and more explicit.

- In `mpdstats`, MPD responses and `now_playing` state now have concrete
types, path lookup uses the correct beets path shape, and player event
handling is narrowed to known states. This makes the control flow easier
to follow and reduces hidden assumptions in the plugin.

- In `thumbnails`, the code stops passing full `Album` objects where
only `album.path` or `artpath` is needed. That separates album metadata
from file-path operations, removes ambiguity around optional
`album.artpath`, and makes thumbnail generation steps more direct.

- Tests were updated to match the narrower method signatures and the
corrected path handling.

- High-level impact: safer internal APIs, clearer data flow, and lower
risk of type-related bugs. The only visible behavior change is that
missing album art is now logged as a warning instead of info.
2026-08-31 11:00:44 +01:00