Commit graph

13879 commits

Author SHA1 Message Date
gaotue
bae4bd159b Try to resolve failing checks 2026-03-23 16:30:10 +01:00
gaotue
b7659fba39 Try to resolve failing checks 2026-03-23 16:19:23 +01:00
gaotue
290502e294 Merge branch 'master' of https://github.com/gaotue/beets 2026-03-23 16:00:22 +01:00
gaotue
0303d4ac1e Recognize format during import. Fix issues raised by copilot 2026-03-23 15:51:15 +01:00
gaotue
414c1da686 Recognize format during import. Fix issues raised by copilot 2026-03-23 15:41:16 +01:00
gaotue
93b4eccc39
Update beets/importer/tasks.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-23 14:46:08 +01:00
gaotue
54f438f176
Update test/test_importer.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-23 14:44:57 +01:00
gaotue
d5a5a0225a
Update beets/importer/tasks.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-23 14:44:24 +01:00
gaotue
b963a14d41
Update beets/importer/tasks.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-23 14:43:53 +01:00
gaotue
d5f64fdba8
Update beets/importer/tasks.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-23 14:43:28 +01:00
gaotue
cccc1fd513
Update beets/importer/tasks.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-23 14:41:36 +01:00
gaotue
8f2b4e50b3
Update test/test_importer.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-23 14:38:49 +01:00
gaotue
5e9ea54429
Update beets/importer/tasks.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-23 14:37:30 +01:00
gaotue
e89648b12b
Update beets/importer/tasks.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-23 14:37:09 +01:00
gaotue
e92c56a5f4
Merge branch 'master' into master 2026-03-23 14:36:29 +01:00
Šarūnas Nejus
72b4c77161
Simplify tagging (#6165)
Refactor item tagging and fix several underlying issues.

### Fixes

- Synchronise all artist list fields. Notably, `artist_sort` /
`artists_sort` and `artist_credit` / `artists_credit` fields have not
been synchronised.
- Fix `overwrite_null` configuration which was previously ignored for
fields defined in `autotag/__init__.py::SPECIAL_FIELDS`.

### Updates
- Move metadata application logic into `Match` objects: add
`Match.apply_metadata`, `AlbumMatch.apply_metadata`,
`AlbumMatch.apply_album_metadata`, and `TrackMatch.apply_metadata`;
callers now use those methods instead of legacy free functions.
- Remove legacy functions from `beets.autotag.__init__`
(`apply_item_metadata`, `apply_album_metadata`, `apply_metadata`) and
related globals (`SPECIAL_FIELDS`, `log`), and export only core types
(`AlbumInfo`, `AlbumMatch`, `TrackInfo`, `TrackMatch`, `Proposal`,
`Recommendation`, `tag_album`, `tag_item`).
- Add structured metadata facilities to `Info` and subclasses:
- `Info.type` class property and `nullable_fields` for per-type
'overwrite_null' config.
- `Info.raw_data` and `Info.item_data` computed properties to apply
`artist_credit` rules, filter nulls, and map media-specific field names.
- `AlbumInfo` and `TrackInfo` extend `raw_data`/`item_data` behavior to
handle album/track specifics (date zeroing, `tracktotal`,
`mb_releasetrackid`, per-disc numbering).
- Introduce `TrackInfo.merge_with_album` to merge track-level data with
album-level fallback for a final item payload.
- Move `correct_list_fields` to `hooks.py` and update it to keep
**unmapped** / **non-media** single/list fields in sync (`artist` <->
`artists`, `albumtype` <-> `albumtypes`, etc.).
- Wire changes through the codebase:
- Pass `Item` objects into `TrackMatch` in `match.tag_item` to enable
item-level metadata application.
- Replace calls to removed `autotag` apply functions with
`Match.apply_metadata` invocations in `beets/importer/tasks.py`,
`beetsplug/bpsync.py`, and `beetsplug/mbsync.py`.
- Update importer logic to set album artist fallbacks for `albumartists`
/ `mb_albumartistids` when missing.
- Add and update tests:
- New `test/autotag/test_hooks.py` and `test/autotag/test_match.py` to
validate new data mapping, list field synchronization, overwrite
behavior, and assignment logic.
2026-03-22 19:34:26 +00:00
gaotue
4b5db35945 Add filename extension for music files with no extension during import 2026-03-22 20:32:23 +01:00
Šarūnas Nejus
5fad834ad2
Ensure we use Distance to initialise Match objects 2026-03-22 19:23:53 +00:00
Šarūnas Nejus
5ae0b82c8a
Add test for from_scratch 2026-03-22 19:23:53 +00:00
Šarūnas Nejus
8a586ec506
Add test for original_date 2026-03-22 19:23:53 +00:00
Šarūnas Nejus
80fc1490e5
Add a note to the changelog 2026-03-22 19:23:53 +00:00
Šarūnas Nejus
74b89b6ed2
autotag: do not sync joined artist to artists field 2026-03-22 19:23:52 +00:00
Šarūnas Nejus
067748a483
autotag: move tests to test_hooks.py 2026-03-22 19:23:52 +00:00
Šarūnas Nejus
df6f5c5826
import: simplify tagging item 2026-03-22 19:23:52 +00:00
Šarūnas Nejus
79787cfd97
tagging: fix list albumartists field 2026-03-22 19:23:52 +00:00
Šarūnas Nejus
f3f132942a
autotag: fix list fields 2026-03-22 19:23:52 +00:00
Šarūnas Nejus
b4ab2d8aa4
tagging: allow nulling singleton fields 2026-03-22 19:23:52 +00:00
Šarūnas Nejus
819b35f6aa
autotag: add a test for overwrite_null configuration 2026-03-22 19:23:52 +00:00
Šarūnas Nejus
da7714aea6
Add feature to exclude albums/songs during auto import (#6452)
Fixes #3523.
2026-03-22 01:54:27 +00:00
kelamg
47148d5100 Fix formatting 2026-03-22 01:46:50 +00:00
kelamg
7556beb33a Revert docstring 2026-03-22 01:46:50 +00:00
kelamg
131930144b Update beetsplug/lyrics.py
Co-authored-by: Šarūnas Nejus <snejus@protonmail.com>
2026-03-22 01:46:50 +00:00
kelamg
97a89e919c Update docs/plugins/lyrics.rst
Co-authored-by: Šarūnas Nejus <snejus@protonmail.com>
2026-03-22 01:46:50 +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
d4dc46591d Update beetsplug/lyrics.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-22 01:46:50 +00:00
kelamg
eacaa09a07 Fix docs formatting 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
Šarūnas Nejus
b09801b24e
docs: Update links to pipx installation guide (#6454)
The [old link](https://pipx.pypa.io/stable/installation/) now responds
with 404.
2026-03-21 18:09:20 +00:00
Andrey Mivrenik
fb46314027 docs: Update links to pipx installation guide 2026-03-21 20:01:46 +02:00
Šarūnas Nejus
03b1ab012c
Refactor dist display (#6444)
## Refactor: Move display logic into `Distance` and `Match` as
properties

Display-related logic previously scattered across `display.py` and
`session.py` is consolidated into the data classes themselves.

### What changed

**`Distance` gains three properties:**

- `penalties` — list of cleaned-up penalty key strings
- `color` — threshold-based `ColorName` derived from the distance value
- `string` — colorized similarity percentage

**`Match` gains two properties:**

- `disambig_string` — formatted comma-separated disambiguation string
- `base_disambig_data` — override point for subclass-specific field
pre-processing (e.g. `media` for `AlbumMatch`,
`index`/`track_alt`/`album` for `TrackMatch`)

**`display.py` / `session.py`:** Standalone functions `dist_string`,
`dist_colorize`, `penalty_string`, `disambig_string`,
`get_album_disambig_fields`, `get_singleton_disambig_fields` are
removed. Call sites now use the properties directly.

A minor fix in `show_match_header` collects output into a list and uses
`textwrap.indent` for a single `ui.print_` call, replacing the previous
per-line prints.

### Impact

- Display logic lives next to the data it describes — easier to find,
easier to test
- `display.py` and `session.py` become thinner; no shared utility
functions to keep in sync
2026-03-20 19:23:54 +00:00
Šarūnas Nejus
2d1461f1d0
Refactor distance and match display into properties
Move disambig string and penalty formatting logic from display.py
into Distance and Match classes as properties.

Add Distance.color, Distance.string, Distance.penalties,
Match.disambig_string, and Match.base_disambig_data to consolidate
display logic closer to the data.

Remove now-redundant standalone functions from display.py and
session.py.
2026-03-17 20:45:32 +00:00
Šarūnas Nejus
1943b14565
Refactor of layout utils (#6442)
This PR refactors import-match layout rendering by centralizing layout
selection and line generation in `beets.util.layout`, simplifying the
`ShowChange` display path, and tightening the layout
data model.

## What Changed
- Added `get_layout_lines()` and `get_layout_method()` in
`beets.util.layout` so layout selection (`column` vs `newline`) is
handled in one place.
- Replaced `Side` from a mutable `TypedDict` with an immutable
`NamedTuple` that exposes derived helpers (`rendered`, prefix/suffix
widths, and rendered width).
- Simplified `split_into_lines()` from a 3-width tuple API to
`(first_width, width)` and removed legacy last-line empty-string
handling.
- Refactored `beets.ui.commands.import_/display.py` `ShowChange` to call
`get_layout_lines()` directly and removed duplicate per-class
layout-selection logic.
- Updated tracklist width calculation to use `Side` helpers and explicit
width assignment via `_replace(width=...)`.
- Reworked `ShowChange` tests into snapshot-style assertions for both
`newline` and `column` layouts, and updated util layout tests to the new
`split_into_lines()` signature.

## Why
- Reduces duplicated wrapping/layout logic across UI code paths.
- Makes layout behavior easier to reason about and test at the utility
boundary.
- Narrows the display layer to orchestration while keeping
transformation/rendering logic in reusable utilities.
- Improves maintainability by moving from loosely typed dict mutation to
a typed, self-describing data structure.
2026-03-17 18:07:34 +00:00
Šarūnas Nejus
a3e94ecac3
Document Side 2026-03-17 17:59:51 +00:00
Šarūnas Nejus
2a003ac709
Refactor ShowChangeTest to use snapshot-style assertions
Replace multiple small tests with two comprehensive snapshot tests
covering the same edge cases and newline and column layouts.

Use BeetsTestCase to ensure that the local dev config is ignored.
2026-03-17 17:59:51 +00:00