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

Add barcode field to AlbumInfo and update related files #5153

Merged
merged 2 commits into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions beets/autotag/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 []
Expand Down Expand Up @@ -175,6 +177,7 @@ def decode(self, codec: str = "utf-8"):
"artist",
"albumtype",
"label",
"barcode",
"artist_sort",
"catalognum",
"script",
Expand Down
1 change: 1 addition & 0 deletions beets/autotag/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def current_metadata(
"disctotal",
"mb_albumid",
"label",
"barcode",
"catalognum",
"country",
"media",
Expand Down
3 changes: 3 additions & 0 deletions beets/autotag/mb.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"catalognum": "catno",
"country": "country",
"label": "label",
"barcode": "barcode",
"media": "format",
"year": "date",
}
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -831,6 +833,7 @@ def _merge_pseudo_and_actual_album(
"original_month",
"original_day",
"label",
"barcode",
"asin",
"style",
"genre",
Expand Down
3 changes: 3 additions & 0 deletions beets/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -1217,6 +1219,7 @@ class Album(LibModel):
"albumtype",
"albumtypes",
"label",
"barcode",
"mb_releasegroupid",
"asin",
"catalognum",
Expand Down
1 change: 1 addition & 0 deletions beets/test/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ def generate_album_info(album_id, track_values):
"albumtype",
"va",
"label",
"barcode",
"artist_sort",
"releasegroup_id",
"catalognum",
Expand Down
1 change: 1 addition & 0 deletions test/test_autotag.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def test_current_metadata_likelies(self):
"disctotal",
"mb_albumid",
"label",
"barcode",
"catalognum",
"country",
"media",
Expand Down
6 changes: 6 additions & 0 deletions test/test_mb.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def _make_release(
},
"country": "COUNTRY",
"status": "STATUS",
"barcode": "BARCODE",
}

if multi_artist_credit:
Expand Down Expand Up @@ -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),
Expand Down
Loading