Skip to content

Commit 6077b7a

Browse files
authored
Merge pull request beetbox#5153 from Dr-Blank/barcode-support
2 parents b09806e + 0e7d35f commit 6077b7a

File tree

7 files changed

+18
-0
lines changed

7 files changed

+18
-0
lines changed

beets/autotag/hooks.py

+3
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def __init__(
9494
month: Optional[int] = None,
9595
day: Optional[int] = None,
9696
label: Optional[str] = None,
97+
barcode: Optional[str] = None,
9798
mediums: Optional[int] = None,
9899
artist_sort: Optional[str] = None,
99100
artists_sort: Optional[List[str]] = None,
@@ -136,6 +137,7 @@ def __init__(
136137
self.month = month
137138
self.day = day
138139
self.label = label
140+
self.barcode = barcode
139141
self.mediums = mediums
140142
self.artist_sort = artist_sort
141143
self.artists_sort = artists_sort or []
@@ -175,6 +177,7 @@ def decode(self, codec: str = "utf-8"):
175177
"artist",
176178
"albumtype",
177179
"label",
180+
"barcode",
178181
"artist_sort",
179182
"catalognum",
180183
"script",

beets/autotag/match.py

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def current_metadata(
102102
"disctotal",
103103
"mb_albumid",
104104
"label",
105+
"barcode",
105106
"catalognum",
106107
"country",
107108
"media",

beets/autotag/mb.py

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"catalognum": "catno",
4646
"country": "country",
4747
"label": "label",
48+
"barcode": "barcode",
4849
"media": "format",
4950
"year": "date",
5051
}
@@ -531,6 +532,7 @@ def album_info(release: Dict) -> beets.autotag.hooks.AlbumInfo:
531532
artists_credit=artists_credit_names,
532533
data_source="MusicBrainz",
533534
data_url=album_url(release["id"]),
535+
barcode=release.get("barcode"),
534536
)
535537
info.va = info.artist_id == VARIOUS_ARTISTS_ID
536538
if info.va:
@@ -831,6 +833,7 @@ def _merge_pseudo_and_actual_album(
831833
"original_month",
832834
"original_day",
833835
"label",
836+
"barcode",
834837
"asin",
835838
"style",
836839
"genre",

beets/library.py

+3
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ class Item(LibModel):
562562
"albumtype": types.STRING,
563563
"albumtypes": types.SEMICOLON_SPACE_DSV,
564564
"label": types.STRING,
565+
"barcode": types.STRING,
565566
"acoustid_fingerprint": types.STRING,
566567
"acoustid_id": types.STRING,
567568
"mb_releasegroupid": types.STRING,
@@ -1162,6 +1163,7 @@ class Album(LibModel):
11621163
"albumtype": types.STRING,
11631164
"albumtypes": types.SEMICOLON_SPACE_DSV,
11641165
"label": types.STRING,
1166+
"barcode": types.STRING,
11651167
"mb_releasegroupid": types.STRING,
11661168
"release_group_title": types.STRING,
11671169
"asin": types.STRING,
@@ -1217,6 +1219,7 @@ class Album(LibModel):
12171219
"albumtype",
12181220
"albumtypes",
12191221
"label",
1222+
"barcode",
12201223
"mb_releasegroupid",
12211224
"asin",
12221225
"catalognum",

beets/test/helper.py

+1
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,7 @@ def generate_album_info(album_id, track_values):
781781
"albumtype",
782782
"va",
783783
"label",
784+
"barcode",
784785
"artist_sort",
785786
"releasegroup_id",
786787
"catalognum",

test/test_autotag.py

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def test_current_metadata_likelies(self):
9090
"disctotal",
9191
"mb_albumid",
9292
"label",
93+
"barcode",
9394
"catalognum",
9495
"country",
9596
"media",

test/test_mb.py

+6
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def _make_release(
6969
},
7070
"country": "COUNTRY",
7171
"status": "STATUS",
72+
"barcode": "BARCODE",
7273
}
7374

7475
if multi_artist_credit:
@@ -379,6 +380,11 @@ def test_parse_status(self):
379380
d = mb.album_info(release)
380381
self.assertEqual(d.albumstatus, "STATUS")
381382

383+
def test_parse_barcode(self):
384+
release = self._make_release(None)
385+
d = mb.album_info(release)
386+
self.assertEqual(d.barcode, "BARCODE")
387+
382388
def test_parse_media(self):
383389
tracks = [
384390
self._make_track("TITLE ONE", "ID ONE", 100.0 * 1000.0),

0 commit comments

Comments
 (0)