From 812fbca9da85853df7c6824eca67d3572029cd81 Mon Sep 17 00:00:00 2001 From: Dr-Blank <64108942+Dr-Blank@users.noreply.github.com> Date: Mon, 18 Mar 2024 12:59:58 -0400 Subject: [PATCH 1/2] Add barcode field to AlbumInfo and update related files --- beets/autotag/hooks.py | 3 +++ beets/autotag/match.py | 1 + beets/autotag/mb.py | 3 +++ beets/library.py | 3 +++ beets/test/helper.py | 1 + 5 files changed, 11 insertions(+) diff --git a/beets/autotag/hooks.py b/beets/autotag/hooks.py index 13c43e8cf2..67546f47c8 100644 --- a/beets/autotag/hooks.py +++ b/beets/autotag/hooks.py @@ -94,6 +94,7 @@ def __init__( month: Optional[int] = None, day: Optional[int] = None, label: Optional[str] = None, + barcode: Optional[str] = None, mediums: Optional[int] = None, artist_sort: Optional[str] = None, artists_sort: Optional[List[str]] = None, @@ -136,6 +137,7 @@ def __init__( self.month = month self.day = day self.label = label + self.barcode = barcode self.mediums = mediums self.artist_sort = artist_sort self.artists_sort = artists_sort or [] @@ -175,6 +177,7 @@ def decode(self, codec: str = "utf-8"): "artist", "albumtype", "label", + "barcode", "artist_sort", "catalognum", "script", diff --git a/beets/autotag/match.py b/beets/autotag/match.py index c79eba2d7e..a256960f73 100644 --- a/beets/autotag/match.py +++ b/beets/autotag/match.py @@ -102,6 +102,7 @@ def current_metadata( "disctotal", "mb_albumid", "label", + "barcode", "catalognum", "country", "media", diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index d1ac7956d9..1fd41fd2c9 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -45,6 +45,7 @@ "catalognum": "catno", "country": "country", "label": "label", + "barcode": "barcode", "media": "format", "year": "date", } @@ -531,6 +532,7 @@ def album_info(release: Dict) -> beets.autotag.hooks.AlbumInfo: artists_credit=artists_credit_names, data_source="MusicBrainz", data_url=album_url(release["id"]), + barcode=release.get("barcode"), ) info.va = info.artist_id == VARIOUS_ARTISTS_ID if info.va: @@ -831,6 +833,7 @@ def _merge_pseudo_and_actual_album( "original_month", "original_day", "label", + "barcode", "asin", "style", "genre", diff --git a/beets/library.py b/beets/library.py index 5ce59852bd..754583f57c 100644 --- a/beets/library.py +++ b/beets/library.py @@ -562,6 +562,7 @@ class Item(LibModel): "albumtype": types.STRING, "albumtypes": types.SEMICOLON_SPACE_DSV, "label": types.STRING, + "barcode": types.STRING, "acoustid_fingerprint": types.STRING, "acoustid_id": types.STRING, "mb_releasegroupid": types.STRING, @@ -1162,6 +1163,7 @@ class Album(LibModel): "albumtype": types.STRING, "albumtypes": types.SEMICOLON_SPACE_DSV, "label": types.STRING, + "barcode": types.STRING, "mb_releasegroupid": types.STRING, "release_group_title": types.STRING, "asin": types.STRING, @@ -1217,6 +1219,7 @@ class Album(LibModel): "albumtype", "albumtypes", "label", + "barcode", "mb_releasegroupid", "asin", "catalognum", diff --git a/beets/test/helper.py b/beets/test/helper.py index b12bfe7abc..9843b51e87 100644 --- a/beets/test/helper.py +++ b/beets/test/helper.py @@ -781,6 +781,7 @@ def generate_album_info(album_id, track_values): "albumtype", "va", "label", + "barcode", "artist_sort", "releasegroup_id", "catalognum", From 0e7d35fd69fd3250353ec9328bdb8cabb6b46f9a Mon Sep 17 00:00:00 2001 From: Dr-Blank <64108942+Dr-Blank@users.noreply.github.com> Date: Mon, 18 Mar 2024 13:23:10 -0400 Subject: [PATCH 2/2] tests for barcode field --- test/test_autotag.py | 1 + test/test_mb.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/test/test_autotag.py b/test/test_autotag.py index 44c68ce9a1..6691348ed6 100644 --- a/test/test_autotag.py +++ b/test/test_autotag.py @@ -90,6 +90,7 @@ def test_current_metadata_likelies(self): "disctotal", "mb_albumid", "label", + "barcode", "catalognum", "country", "media", diff --git a/test/test_mb.py b/test/test_mb.py index 605d126f9e..5290b30212 100644 --- a/test/test_mb.py +++ b/test/test_mb.py @@ -69,6 +69,7 @@ def _make_release( }, "country": "COUNTRY", "status": "STATUS", + "barcode": "BARCODE", } if multi_artist_credit: @@ -379,6 +380,11 @@ def test_parse_status(self): d = mb.album_info(release) self.assertEqual(d.albumstatus, "STATUS") + def test_parse_barcode(self): + release = self._make_release(None) + d = mb.album_info(release) + self.assertEqual(d.barcode, "BARCODE") + def test_parse_media(self): tracks = [ self._make_track("TITLE ONE", "ID ONE", 100.0 * 1000.0),