Skip to content

Commit

Permalink
Merge pull request beetbox#5134 from InvisibleFunction/fix-media-headers
Browse files Browse the repository at this point in the history
Fix Media Headers on Import
  • Loading branch information
JOJ0 authored Mar 16, 2024
2 parents 3548e35 + b9ab0c9 commit b09806e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
8 changes: 6 additions & 2 deletions beets/autotag/mb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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([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:
info.media = "Media"

if config["musicbrainz"]["genres"]:
sources = [
Expand Down
10 changes: 6 additions & 4 deletions beets/ui/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,14 +453,16 @@ 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 ""

Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +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 when
importing with MusicBrainz as the data source
:bug:`4947`

For plugin developers:

Expand Down

0 comments on commit b09806e

Please sign in to comment.