From 11932eb73285da589d0e65d1723f218adc3a2367 Mon Sep 17 00:00:00 2001 From: InvisibleFunction <3682184+InvisibleFunction@users.noreply.github.com> Date: Sun, 3 Mar 2024 10:53:39 -0500 Subject: [PATCH 1/4] Fix Media Headers on Import --- beets/autotag/mb.py | 8 ++++++-- beets/ui/commands.py | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index 0bd47f1e6e..804a37db88 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -595,8 +595,12 @@ def album_info(release: Dict) -> beets.autotag.hooks.AlbumInfo: # Media (format). if release["medium-list"]: - first_medium = release["medium-list"][0] - info.media = first_medium.get("format") + # If all media are the same, use that medium name + if len(set([x.get("format") for x in release["medium-list"]])) == 1: + info.media = release["medium-list"][0].get("format") + # Otherwise, let's just call it "Media" + else: + info.media = "Media" if config["musicbrainz"]["genres"]: sources = [ diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 87fc007821..67c03f7d63 100755 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -453,14 +453,14 @@ def show_match_details(self): def make_medium_info_line(self, track_info): """Construct a line with the current medium's info.""" - media = self.match.info.media or "Media" + track_media = track_info.get("media", "Media") # Build output string. if self.match.info.mediums > 1 and track_info.disctitle: - return f"* {media} {track_info.medium}: {track_info.disctitle}" + return f"* {track_media} {track_info.medium}: {track_info.disctitle}" elif self.match.info.mediums > 1: - return f"* {media} {track_info.medium}" + return f"* {track_media} {track_info.medium}" elif track_info.disctitle: - return f"* {media}: {track_info.disctitle}" + return f"* {track_media}: {track_info.disctitle}" else: return "" From 94e294581b44758e1fb533ab7308e620f3e839fd Mon Sep 17 00:00:00 2001 From: InvisibleFunction <3682184+InvisibleFunction@users.noreply.github.com> Date: Wed, 6 Mar 2024 09:12:58 -0500 Subject: [PATCH 2/4] Update Changelog --- docs/changelog.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 0b5e195774..798f5726c7 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -292,6 +292,8 @@ Bug fixes: and caching in `zsh`. :bug:`3546` * Remove unused functions :bug:`5103` +* Fix bug where all media types are reported as the first media type + :bug:`5134` For plugin developers: From 33c8ae7a4b0c3df16b21ccd95287f381408c15af Mon Sep 17 00:00:00 2001 From: InvisibleFunction <3682184+InvisibleFunction@users.noreply.github.com> Date: Thu, 7 Mar 2024 09:11:54 -0500 Subject: [PATCH 3/4] Update in response to comments --- beets/autotag/mb.py | 2 +- docs/changelog.rst | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index 804a37db88..d1ac7956d9 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -596,7 +596,7 @@ def album_info(release: Dict) -> beets.autotag.hooks.AlbumInfo: # Media (format). if release["medium-list"]: # If all media are the same, use that medium name - if len(set([x.get("format") for x in release["medium-list"]])) == 1: + if len(set([m.get("format") for m in release["medium-list"]])) == 1: info.media = release["medium-list"][0].get("format") # Otherwise, let's just call it "Media" else: diff --git a/docs/changelog.rst b/docs/changelog.rst index 798f5726c7..72186603d5 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -292,8 +292,9 @@ Bug fixes: and caching in `zsh`. :bug:`3546` * Remove unused functions :bug:`5103` -* Fix bug where all media types are reported as the first media type - :bug:`5134` +* Fix bug where all media types are reported as the first media type when + importing with MusicBrainz as the data source + :bug:`4947` For plugin developers: From b9ab0c98673093a087d8168add450a21407887b3 Mon Sep 17 00:00:00 2001 From: InvisibleFunction <3682184+InvisibleFunction@users.noreply.github.com> Date: Sat, 9 Mar 2024 14:28:17 -0500 Subject: [PATCH 4/4] Run black --- beets/ui/commands.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 67c03f7d63..755c148fce 100755 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -456,7 +456,9 @@ def make_medium_info_line(self, track_info): track_media = track_info.get("media", "Media") # Build output string. if self.match.info.mediums > 1 and track_info.disctitle: - return f"* {track_media} {track_info.medium}: {track_info.disctitle}" + return ( + f"* {track_media} {track_info.medium}: {track_info.disctitle}" + ) elif self.match.info.mediums > 1: return f"* {track_media} {track_info.medium}" elif track_info.disctitle: