Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from beetbox:master #1

Open
wants to merge 1,902 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
1902 commits
Select commit Hold shift + click to select a range
bc16ed1
Increment version to 2.1.0
snejus Nov 22, 2024
4a5b9a2
Release: fix github-tag-action version
snejus Nov 22, 2024
cf3acec
Release: temporarily ignore errors with bumping version and pypi push
snejus Nov 22, 2024
0780bf3
Release: make sure release artefacts are present for the tagging job
snejus Nov 22, 2024
979f123
Revert "Release: temporarily ignore errors with bumping version and p…
snejus Nov 22, 2024
65e935b
Perform a regex substitution in the substitute plugin (#5357)
snejus Nov 22, 2024
6444111
bitesize to good first issue: Update changelog.rst (#5477)
snejus Nov 22, 2024
176661b
Changelog notes need to go under Unreleased
snejus Nov 22, 2024
3798ac5
Add a quick check for MST Store Python install
arogl Oct 19, 2024
f0f77aa
Update related window files to match 3.8
arogl Oct 19, 2024
3750c63
Manually format messages
arogl Oct 19, 2024
22810b6
Windows & VSCode & Python
arogl Oct 19, 2024
ec4b26f
Update changelog
arogl Oct 19, 2024
1d63bf9
Update error logging as suggested
arogl Oct 22, 2024
ef328ed
Add a quick check for MST Store Python install (#5470)
snejus Nov 22, 2024
5f4fe21
Update docs/guides/main.rst
RollingStar Nov 22, 2024
79d7d48
ARM footnotes
RollingStar Nov 22, 2024
db71444
Disable OIDC for coverage uploads from forks
snejus Nov 23, 2024
32e9e58
Fix SACD Imports
InvisibleFunction Nov 23, 2024
0e6ba45
Fix Hybrid SACD importing (#5149)
snejus Nov 23, 2024
37a2cec
Fix coverage upload from forks: Attempt #2 (#5514)
snejus Nov 23, 2024
9c4d4d9
Include test files, manual to sdist
snejus Nov 26, 2024
f5a0246
Fixup changelog rst formatting for this and prev version
snejus Nov 26, 2024
a7f00ea
Fix missing changelog in the release notes
snejus Nov 26, 2024
f39eb98
Update dependencies
snejus Nov 26, 2024
336b5b3
Skip autobpm tests if librosa isn't available
stefanor Nov 25, 2024
0eab8b6
Skip autobpm tests if librosa isn't available (#5516)
snejus Nov 30, 2024
242d0e8
Include tests and manual in sdist and update dependencies, and includ…
snejus Dec 2, 2024
27d66d4
Change `zero` documentation mentions of genre to genres (#5486)
snejus Dec 2, 2024
01f1faf
Release: do not fail when mastodon auth fails
snejus Dec 2, 2024
f92c0ec
Increment version to 2.2.0
snejus Dec 2, 2024
eafae03
Merge branch 'beetbox:master' into arm-info
RollingStar Dec 5, 2024
4098790
Update main.rst
RollingStar Dec 5, 2024
755e825
ARM install instructions (#5460)
snejus Dec 5, 2024
0936025
lyrics: Fallback to plain lyrics if synced not available
edgars-supe Jan 25, 2024
af41eef
lyrics: Fallback to plain lyrics if synced lyrics not available (#5089)
snejus Dec 7, 2024
ed3a53f
Exclude plugin tests, include all files from MANIFEST.in
snejus Dec 5, 2024
71eb1bc
Release: create tag right after commit version update
snejus Dec 6, 2024
3cc129b
Package: fix release workflow, exclude plugin tests, include all file…
snejus Dec 10, 2024
88deb07
Drop Python 3.8 from the package, update dependencies
snejus Nov 17, 2024
7be8f9c
Update CI config, minimum ruff version, docs and add changelog note
snejus Nov 17, 2024
51f9dd2
Use PEP585 lowercase collections typing annotations
snejus Nov 17, 2024
fbfdfd5
Remove unnecessary quotes from types
snejus Nov 17, 2024
7ef1b61
Replace Union types by PEP604 pipe character
snejus Nov 17, 2024
161b052
Update deprecated imports
snejus Nov 17, 2024
5c81f94
Move imports required for typing under the TYPE_CHECKING block
snejus Nov 22, 2024
22163d7
Remove support for Python 3.8 (#5508)
snejus Dec 10, 2024
550a9a8
Fix mb_artistid, mb_albumartistid, albumtype diff issue
snejus Dec 14, 2024
a091c2e
Ensure that list fields are corrected for album metadata too
snejus Dec 15, 2024
3b0c477
Define unique_list and dedupe
snejus Dec 15, 2024
9110a11
Stop perpetually writing `mb_artistid`, `mb_albumartistid` and `album…
snejus Dec 15, 2024
994f9b8
pyproject.toml: don't install docs et al into the wheel
ArsenArsen Dec 18, 2024
bcf516b
Properly type db on the model, sort out generic types issues (#5545)
snejus Dec 19, 2024
34af24b
Add some error ignoring for copystat call in move()
aereaux Dec 20, 2024
2277e2a
Use shutil.move() to move files. (#5123)
snejus Dec 26, 2024
420117b
Track assignment: replace munkres with lapjv
snejus Dec 27, 2024
4c8d75f
Cache track_length_grace and track_length_max access
snejus Dec 27, 2024
faf7529
Replace munkres with lapjv for track assignment (#5564)
snejus Dec 27, 2024
bcc79a5
Future proof BucketPluginTest.test_year_single_year_last_folder
stefanor Dec 27, 2024
ef4e983
Add test for changelog formatting
snejus Dec 2, 2024
aff43d8
Remove poe output
snejus Dec 2, 2024
e9076ff
Unindent list items in the changelog
snejus Dec 3, 2024
914dbcb
Cache deps
snejus Dec 3, 2024
13e83cd
:facepalm:
snejus Dec 3, 2024
7b9625b
Test rst to md conversion
snejus Dec 3, 2024
d98226a
Fix ordering bullet point lists
snejus Dec 4, 2024
dd96928
Test nested bullet points conversion
snejus Dec 4, 2024
c26473e
Fix nested bullet points conversion
snejus Dec 4, 2024
89afb8c
Test wrapped line starting with the username role
snejus Dec 4, 2024
806c170
Fix wrapped line starting with the username role
snejus Dec 4, 2024
6d602ef
Add a test for literal code block
snejus Dec 4, 2024
0b905e1
Ignore literal code blocks when making headers
snejus Dec 4, 2024
779ba79
Cap maximum sub-section name length
snejus Dec 4, 2024
e579df0
Can we link users to plugin docs?
snejus Dec 4, 2024
0f45791
Fix Unreleased changelog template
snejus Dec 4, 2024
555cf32
Remove the temporary testing workflow
snejus Dec 4, 2024
eb557f7
Resolve all URLs for markdown
snejus Dec 5, 2024
fdd365f
Future proof BucketPluginTest.test_year_single_year_last_folder (#5566)
snejus Dec 29, 2024
5882e2c
Fix sorting on missing int fields
valrus Dec 29, 2024
1af9df2
add another benefit of item_types
valrus Dec 29, 2024
723e928
Add changelog item
valrus Dec 29, 2024
e9a77ca
format
valrus Dec 29, 2024
0d6393e
Fix track matching
snejus Dec 31, 2024
084cf64
matching: add additional test cases and refactor tests
snejus Dec 31, 2024
ef902ea
item assignment: set track distance configuration in tests explicitly
snejus Dec 31, 2024
21c734b
patch rather than overwriting Item
valrus Dec 31, 2024
342ac28
improve names
valrus Dec 31, 2024
ef00b1c
simplify non-string missing field condition
valrus Dec 31, 2024
7f469ee
format
valrus Dec 31, 2024
80a10c7
lint
valrus Dec 31, 2024
c9afb86
Add types-mock for typechecking
valrus Jan 1, 2025
f91f096
Fix sorting on missing non-string fields (#5570)
snejus Jan 1, 2025
c01d059
Fix track matching regression (#5571)
snejus Jan 4, 2025
801bac5
Release: Fix changelog formatting (#5529)
snejus Jan 4, 2025
d4ada3c
Fix track-level genre handling in lastgenre plugin
JOJ0 Aug 30, 2023
9ec2a81
Streamline lastgenre singleton log with album log
JOJ0 May 21, 2023
18e76f0
Prevent album genre inherit only when source:track
JOJ0 Nov 3, 2023
9d09d6f
Fix lastgenre source:track handling during imports
JOJ0 Nov 4, 2023
0c10635
Another round of lastgenre logging nitpicks
JOJ0 Nov 4, 2023
55c0f7a
Changelog for PR #5582
JOJ0 Jan 8, 2025
bcc91ff
lastgenre: Fix track-level handling and streamline logging (#5582)
JOJ0 Jan 9, 2025
64b3481
Take into account Sphinx updates in docs and release script
snejus Jan 12, 2025
5fc92c9
Make sure release script is tested on Ubuntu
snejus Jan 12, 2025
0a53a93
Fix release formatting for new versions of pandoc
snejus Jan 13, 2025
044712b
Add now missing libcairo dependency
snejus Jan 13, 2025
3bb8af8
Ignore this test
snejus Jan 13, 2025
a1e8572
Enable colors in the docs
snejus Jan 19, 2025
f409741
Fix Sphinx configuration post-update (#5588)
snejus Jan 19, 2025
69faa58
Unify query construction logic
snejus May 8, 2024
d22c497
Use table-qualified names in any field query
snejus Dec 7, 2024
4650f65
Add Item.any_writable_media_field_query method for BPD search
snejus Jun 16, 2024
a8ad7df
Use Item.field_query for queries that receive user input
snejus Dec 7, 2024
bd30439
Handle ambiguous column names in queries involving 'any' field and a …
snejus Jan 19, 2025
e99d457
Rewrite lyrics integration tests
snejus Oct 2, 2024
3b73a26
Address failing google sources tests
snejus Oct 2, 2024
29a3dd5
Remove redundant lyrics test files
snejus Aug 28, 2024
b9bc2cb
lyrics: isolate test configuration
snejus Jan 12, 2025
fc49902
Refactor lyrics backend tests to use pytest fixtures
snejus Oct 2, 2024
35dcfe5
Configure integrated lyrics tests to only run on lyrics code changes
snejus Oct 2, 2024
67e0af5
Remove outdated GeniusLyrics test
snejus Oct 2, 2024
14fd151
Refactor test_slug to pytest
snejus Oct 2, 2024
f674d65
Refactor search_pairs tests to use pytest parametrize
snejus Oct 3, 2024
767a83f
Refactor utils test cases to use pytest.mark.parametrize
snejus Oct 3, 2024
0a12d07
Do not attempt to fetch lyrics with empty data
snejus Oct 3, 2024
334bbde
Make album, duration required for LyricsPlugin.fetch
snejus Sep 20, 2024
c250bfa
Google: test the entire fetch method
snejus Oct 18, 2024
e5c006d
Test lyrics texts explicitly
snejus Jan 19, 2025
38c8209
Refactor lyrics tests, do not search for empty metadata (#5452)
snejus Jan 19, 2025
8d4a569
Fix fetching lyrics from lrclib
snejus Sep 4, 2024
a398fbe
LRCLib: Improve exception handling
snejus Aug 27, 2024
30379bc
Update lyrics.sources configuration to prioritize lrclib
snejus Aug 27, 2024
2fb72c6
lyrics/LRCLib: handle instrumental lyrics
snejus Sep 27, 2024
618c3a2
Try to GET LRCLib lyrics before searching
snejus Oct 18, 2024
33aafdd
Remove trailing spaces in synced lyrics lines without text
snejus Oct 23, 2024
bb5f3e0
lyrics: sort lrclib lyrics by synced field and query search first
snejus Dec 15, 2024
f709ac1
Fix lrclib lyrics (#5406)
snejus Jan 20, 2025
4ff8c34
Quickfix lastgenre always overwriting multi-genre
JOJ0 May 3, 2023
6ab6ae2
Fix track-level genre handling in lastgenre plugin
JOJ0 Aug 30, 2023
7d6a404
Handle dups of existing genres in lastgenre plugin
JOJ0 Jun 17, 2023
517c037
Refactor lastgenre keep_allowed to list comprehension
JOJ0 Nov 16, 2023
fe466f4
Use separator as configured instead of hardcoding
JOJ0 Nov 16, 2023
4ea8650
Use provided deduplicate function for keep_allowed
JOJ0 Nov 16, 2023
318c020
Add lastgenre keep_allowed options (-k/-K)
JOJ0 Sep 14, 2024
40760a0
Docs for lastgenre keep_allowed/force
JOJ0 Sep 15, 2024
d935ec8
Implement --force and --keep-allowed behaviours
JOJ0 Sep 17, 2024
11f7a98
Refactor keep/new genres combination
JOJ0 Oct 31, 2024
2c86af3
Quickfix constant msgpack poetry issue
JOJ0 Nov 1, 2024
cbc33e7
lastgenre: Add comments over groups of methods
JOJ0 Nov 1, 2024
70d641c
Experiment with test_lastgenre
JOJ0 Dec 15, 2024
6866fce
Fix default for _dedup_genre whitelist arg
JOJ0 Jan 2, 2025
462a7a5
_combine_and_label return None not empty str
JOJ0 Jan 2, 2025
b0e0f1b
Fallback to next stage when fetch_ returns None
JOJ0 Jan 2, 2025
a434ecf
Refactor _get_genre test to parametrized pytest
JOJ0 Jan 1, 2025
1c14574
Add lastgenre testcase with unicode \0 separator
JOJ0 Jan 2, 2025
90c48ea
Temporary lastgenre debug messages for @arsaboo
JOJ0 Jan 3, 2025
4c7d0c9
Clarify lastgenre _is_allowed docstring
JOJ0 Jan 3, 2025
998f2f8
Rewrite docs for keep_allowed/existing change
JOJ0 Jan 3, 2025
d0abc0d
Rename lastgenre option, refactor, new default
JOJ0 Jan 3, 2025
3e452e7
lastgenre test _get_genre for renamed keep_existing
JOJ0 Jan 3, 2025
5e6d917
Fix lastgenre "count" issue
JOJ0 Jan 4, 2025
9f5b4ba
Handle genres as list, count/format/str helper
JOJ0 Jan 5, 2025
50e2619
Refactor lastgenre mocked fetchers return list
JOJ0 Jan 5, 2025
b4590ec
Fix/add lastgenre fallback tests
JOJ0 Jan 5, 2025
3d03647
lastgenre _is_allowed detailed logging
JOJ0 Jan 5, 2025
569ba73
Refactor again _combine_and_label_genres
JOJ0 Jan 6, 2025
dd3a74c
Fix lastgenre limit to count test
JOJ0 Jan 6, 2025
13ae699
Fix _dedup_genre, ensure lower case
JOJ0 Jan 7, 2025
6cd0007
_resolve_genre as list tests, add test_to_delimited_string
JOJ0 Jan 6, 2025
37fc1b6
Final lastgenre plugin linting
JOJ0 Jan 8, 2025
a49f12b
Final lastgenre docs changes
JOJ0 Jan 8, 2025
a717998
Add a temporary log around whitelist setup
JOJ0 Jan 8, 2025
da98d37
Temporary debug messages in _sort_by_depth
JOJ0 Jan 9, 2025
1aca398
Fix previous temp log messages
JOJ0 Jan 9, 2025
847b726
Fix most popular track genre fetching (VA albums)
JOJ0 Jan 9, 2025
8d43517
Remove all lastgenre temporary debug logging
JOJ0 Jan 9, 2025
6b41743
Polish 'fetched last.fm tags' debug message
JOJ0 Jan 9, 2025
593f546
Apply type hint suggestions from review
JOJ0 Jan 11, 2025
b476560
Integrate _format_tag in _to_delimited_...
JOJ0 Jan 11, 2025
bd0c024
Apply temp logging leftover review suggestions
JOJ0 Jan 11, 2025
e1fe6fd
Prevent album genre inherit only when source:track
JOJ0 Nov 3, 2023
1497453
Revert "Quickfix constant msgpack poetry issue"
JOJ0 Jan 12, 2025
79b5379
Refactor and rename _is_valid() helper
JOJ0 Jan 11, 2025
2a80a10
Use util.unique_list in fav of deduplicate
JOJ0 Jan 12, 2025
d358a24
Remove redundant unique_list call in _combine
JOJ0 Jan 12, 2025
f698f21
Ensure _resolve returns list, add type hint
JOJ0 Jan 12, 2025
f16e671
Simplify _get_genre keep_existing conditional
JOJ0 Jan 13, 2025
4580757
Simplify _last_lookup()
JOJ0 Jan 12, 2025
ed68bc0
Refactor _get_genre, simplify _combine_genre
JOJ0 Jan 13, 2025
6e3f5b3
Fix type hints, Refactor existing genres method
JOJ0 Jan 13, 2025
ec10507
Return as-is if no-force
JOJ0 Jan 19, 2025
ca5e471
Refactor again _last_lookup
JOJ0 Jan 21, 2025
4e8948d
Rework new & refine existing lastgenre docs chapters
JOJ0 Jan 21, 2025
bb3f9c5
lastgenre new defaults, remove config sanity check
JOJ0 Jan 21, 2025
c3f0abd
Fix docstring _resolve_genres
JOJ0 Jan 21, 2025
7ff06df
Simplify _get_existing_genres()
JOJ0 Jan 21, 2025
5d94eb3
Fix _get_genre docstring
JOJ0 Jan 21, 2025
3cc2a5e
Fix Tuple with tuple in sources property
JOJ0 Jan 21, 2025
169ec20
Remove unused _polish_existing_genres
JOJ0 Jan 21, 2025
c9187b4
Don't uselessly split/join early returned genres
JOJ0 Jan 21, 2025
6e6a0ad
Return empty tuple instead of disabling type issue
JOJ0 Jan 21, 2025
8da98e5
Further clarify lastgenre log-labels
JOJ0 Jan 21, 2025
d5cf376
Include lower-casing in _get_existing already
JOJ0 Jan 21, 2025
4490187
Clarify log-label: keep any, no-force
JOJ0 Jan 21, 2025
d703a7f
Fix tests for log-label changes
JOJ0 Jan 21, 2025
4f0837c
Revert "Include lower-casing in _get_existing already"
JOJ0 Jan 21, 2025
6530d76
Revert "Simplify _get_existing_genres()"
JOJ0 Jan 21, 2025
1219b43
Fix a test: no-force always early returns
JOJ0 Jan 21, 2025
92e84a2
Make sure existing genres are ALWAYS looked at
JOJ0 Jan 21, 2025
34b9021
Fix test_get_genrer - configure first
JOJ0 Jan 21, 2025
261379f
Add test_get_genre case proving no-force keeps any
JOJ0 Jan 21, 2025
87d9f57
In _get_existing_genres ensure empty string ignore
JOJ0 Jan 21, 2025
86e1bd4
Single place for whitelist/any log-label suffix
JOJ0 Jan 22, 2025
1b05a12
Revert "Further clarify lastgenre log-labels"
JOJ0 Jan 22, 2025
f695d46
Main variables init in _get_genre()
JOJ0 Jan 22, 2025
5d9d884
Fix a lastgenre test
JOJ0 Jan 22, 2025
24a3394
Fix keep-none option, reword help
JOJ0 Jan 22, 2025
2f40b31
Add lastgenre --no-force, reword help
JOJ0 Jan 22, 2025
2708be2
Final nitpicks on lastgenre --help wording
JOJ0 Jan 23, 2025
9d4653f
Final lastgenre docstring nitpicks
JOJ0 Jan 23, 2025
9682f24
Lastgenre: New config option `keep_existing` (#4982)
JOJ0 Jan 23, 2025
346071c
Add missing changelog for #4982
JOJ0 Jan 24, 2025
1ae4677
Added a quick checkpoint to ensure the config file is set up correctl…
miertla Jun 15, 2023
6161b44
Apply config-sanity-check suggestion in docs
JOJ0 Jan 24, 2025
80bc539
Checkpoint to make sure config file is set up correctly added to the…
JOJ0 Jan 24, 2025
2ff5750
Apply dist_thresh to Genius and Google backends
snejus Oct 12, 2024
c40db10
Make lyrics plugin documentation slightly more clear
snejus Aug 27, 2024
06eac79
Centralize requests setup with requests.Session
snejus Sep 4, 2024
283c513
Centralise request error handling
snejus Oct 13, 2024
cb29605
Include class name in the log messages
snejus Sep 6, 2024
7c2fb31
Leave a single chef in the kitchen
snejus Sep 11, 2024
dd9f178
Do not try to strip cruft from the parsed lyrics text.
snejus Oct 19, 2024
f94d276
Use a single slug implementation
snejus Sep 6, 2024
8bdc2c6
lyrics: Add symbols for better visual feedback in the logs
snejus Sep 19, 2024
8a1ce27
lyrics: Do not write item unless lyrics have changed
snejus Sep 27, 2024
55b7824
Replace custom unescape implementation by html.unescape
snejus Oct 7, 2024
54fc67b
Remove extract_text_between
snejus Oct 7, 2024
745c5eb
Genius: refactor and simplify
snejus Oct 9, 2024
12c5eaa
Unite Genius, Tekstowo and Google backends under the same interface
snejus Oct 13, 2024
c5c4138
Google: Refactor and improve
snejus Oct 13, 2024
7055464
Create Html class for cleaning up the html text
snejus Oct 13, 2024
07d372c
Google: prioritise Songlyrics and AZlyrics sources
snejus Oct 13, 2024
b2402b1
Google: make sure we do not return the captcha text
snejus Oct 13, 2024
04054ca
Remove dependency existence checks
snejus Oct 26, 2024
bdc564a
Tidy up handling of backends
snejus Oct 26, 2024
734bcc2
Append source to the lyrics
snejus Oct 19, 2024
858c135
Xfail Songlyrics source
snejus Oct 19, 2024
39c479f
Google: add support for dainuzodziai.lt
snejus Oct 26, 2024
7389f24
Do not search for Various Artists, split titles by ' / '
snejus Jan 19, 2025
dab9a0d
Bring back Tekstowo search
snejus Dec 15, 2024
a1c0ebd
Lyrics: Refactor Genius, Google backends, and consolidate common func…
snejus Jan 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix mb_artistid, mb_albumartistid, albumtype diff issue
  • Loading branch information
snejus committed Dec 14, 2024
commit 550a9a82b16844253a035dedf75b33e4a4b5ec74
39 changes: 39 additions & 0 deletions beets/autotag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,43 @@ def apply_album_metadata(album_info: AlbumInfo, album: Album):
_apply_metadata(album_info, album)


def ensure_consistent_list_fields(i: Item) -> None:
"""Synchronise single and list values for the list fields that we use.

That is, ensure the same value in the single field and the first element
in the list.

For context, the value we set as, say, ``mb_artistid`` is simply ignored:
Under the current :class:`MediaFile` implementation, fields ``albumtype``,
``mb_artistid`` and ``mb_albumartistid`` are mapped to the first element of
``albumtypes``, ``mb_artistids`` and ``mb_albumartistids`` respectively.

This means setting ``mb_artistid`` has no effect. However, beets
functionality still assumes that ``mb_artistid`` is independent and stores
its value in the database. If ``mb_artistid`` != ``mb_artistids[0]``,
``beet write`` command thinks that ``mb_artistid`` is modified and tries to
update the field in the file. Of course nothing happens, so the same diff
is shown every time the command is run.

We can avoid this issue by ensuring that ``mb_artistid`` has the same value
as ``mb_artistids[0]``, and that's what this function does.
"""
if aid := i.mb_artistid:
i.mb_artistids = list(dict.fromkeys([aid, *i.mb_artistids]))
elif aids := i.mb_artistids:
i.mb_artistid = aids[0]

if aaid := i.mb_albumartistid:
i.mb_albumartistids = list(dict.fromkeys([aaid, *i.mb_albumartistids]))
elif aaids := i.mb_albumartistids:
i.mb_albumartistid = aaids[0]

if atype := i.albumtype:
i.albumtypes = list(dict.fromkeys([atype, *i.albumtypes]))
elif atypes := i.albumtypes:
i.albumtype = atypes[0]


def apply_metadata(album_info: AlbumInfo, mapping: Mapping[Item, TrackInfo]):
"""Set the items' metadata to match an AlbumInfo object using a
mapping from Items to TrackInfo objects.
Expand Down Expand Up @@ -250,6 +287,8 @@ def apply_metadata(album_info: AlbumInfo, mapping: Mapping[Item, TrackInfo]):
item.mb_albumartistids = album_info.artists_ids
item.mb_releasegroupid = album_info.releasegroup_id

ensure_consistent_list_fields(item)

# Compilation flag.
item.comp = album_info.va

Expand Down
8 changes: 8 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ Bug fixes:
have before the introduction of Poetry.
:bug:`5531`
:bug:`5526`
* :ref:`write-cmd`: Fix the issue where for certain files differences in
``mb_artistid``, ``mb_albumartistid`` and ``albumtype`` fields are shown on
every attempt to write tags. Note: your music needs to be reimported with
``beet import -LI`` or synchronised with ``beet mbsync`` in order to fix
this!
:bug:`5265`
:bug:`5371`
:bug:`4715`

For packagers:

Expand Down
39 changes: 38 additions & 1 deletion test/test_autotag.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@
import pytest

from beets import autotag, config
from beets.autotag import AlbumInfo, TrackInfo, match
from beets.autotag import (
AlbumInfo,
TrackInfo,
ensure_consistent_list_fields,
match,
)
from beets.autotag.hooks import Distance, string_dist
from beets.library import Item
from beets.test.helper import BeetsTestCase
Expand Down Expand Up @@ -1040,3 +1045,35 @@ def test_ampersand_expansion(self):
def test_accented_characters(self):
dist = string_dist("\xe9\xe1\xf1", "ean")
assert dist == 0.0


@pytest.mark.parametrize(
"single_field,list_field",
[
("mb_artistid", "mb_artistids"),
("mb_albumartistid", "mb_albumartistids"),
("albumtype", "albumtypes"),
],
)
@pytest.mark.parametrize(
"single_value,list_value",
[
(None, []),
(None, ["1"]),
(None, ["1", "2"]),
("1", []),
("1", ["1"]),
("1", ["1", "2"]),
("1", ["2", "1"]),
],
)
def test_ensure_consistent_list_fields(
single_field, list_field, single_value, list_value
):
data = {single_field: single_value, list_field: list_value}
item = Item(**data)

ensure_consistent_list_fields(item)

single_val, list_val = item[single_field], item[list_field]
assert (not single_val and not list_val) or single_val == list_val[0]