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

Fix musicbrainz genres fetching #5609

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
21 changes: 13 additions & 8 deletions beets/autotag/mb.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

log = logging.getLogger("beets")

RELEASE_INCLUDES = [

Check failure on line 77 in beets/autotag/mb.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Unsupported left operand type for & ("list[str]")
"artists",
"media",
"recordings",
Expand All @@ -89,7 +89,17 @@
"isrcs",
"url-rels",
"release-rels",
]
"tags",
] & set(musicbrainzngs.VALID_INCLUDES["release"])

TRACK_INCLUDES = [

Check failure on line 95 in beets/autotag/mb.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Unsupported left operand type for & ("list[str]")
"artists",
"aliases",
"isrcs",
"work-level-rels",
"artist-rels",
] & set(musicbrainzngs.VALID_INCLUDES["recording"])

BROWSE_INCLUDES = [
"artist-credits",
"work-rels",
Expand All @@ -101,11 +111,6 @@
BROWSE_INCLUDES.append("work-level-rels")
BROWSE_CHUNKSIZE = 100
BROWSE_MAXTRACKS = 500
TRACK_INCLUDES = ["artists", "aliases", "isrcs"]
if "work-level-rels" in musicbrainzngs.VALID_INCLUDES["recording"]:
TRACK_INCLUDES += ["work-level-rels", "artist-rels"]
if "genres" in musicbrainzngs.VALID_INCLUDES["recording"]:
RELEASE_INCLUDES += ["genres"]


def track_url(trackid: str) -> str:
Expand All @@ -132,7 +137,7 @@
)


def _preferred_alias(aliases: list):

Check failure on line 140 in beets/autotag/mb.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Missing type parameters for generic type "list"
"""Given an list of alias structures for an artist credit, select
and return the user's preferred alias alias or None if no matching
alias is found.
Expand Down Expand Up @@ -173,7 +178,7 @@
default release event if a preferred event is not found.
"""
countries = config["match"]["preferred"]["countries"].as_str_seq()
countries = cast(Sequence, countries)

Check failure on line 181 in beets/autotag/mb.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Missing type parameters for generic type "Sequence"

for country in countries:
for event in release.get("release-event-list", {}):
Expand All @@ -187,7 +192,7 @@


def _multi_artist_credit(
credit: list[dict], include_join_phrase: bool

Check failure on line 195 in beets/autotag/mb.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Missing type parameters for generic type "dict"
) -> tuple[list[str], list[str], list[str]]:
"""Given a list representing an ``artist-credit`` block, accumulate
data into a triple of joined artist name lists: canonical, sort, and
Expand Down Expand Up @@ -235,7 +240,7 @@
)


def _flatten_artist_credit(credit: list[dict]) -> tuple[str, str, str]:

Check failure on line 243 in beets/autotag/mb.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Missing type parameters for generic type "dict"
"""Given a list representing an ``artist-credit`` block, flatten the
data into a triple of joined artist name strings: canonical, sort, and
credit.
Expand All @@ -250,7 +255,7 @@
)


def _artist_ids(credit: list[dict]) -> list[str]:

Check failure on line 258 in beets/autotag/mb.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Missing type parameters for generic type "dict"
"""
Given a list representing an ``artist-credit``,
return a list of artist IDs
Expand All @@ -277,7 +282,7 @@


def track_info(
recording: dict,

Check failure on line 285 in beets/autotag/mb.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Missing type parameters for generic type "dict"
index: int | None = None,
medium: int | None = None,
medium_index: int | None = None,
Expand Down Expand Up @@ -401,7 +406,7 @@
setattr(info, key, date_num)


def album_info(release: dict) -> beets.autotag.hooks.AlbumInfo:

Check failure on line 409 in beets/autotag/mb.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Missing type parameters for generic type "dict"
"""Takes a MusicBrainz release result dictionary and returns a beets
AlbumInfo object containing the interesting data about that release.
"""
Expand Down Expand Up @@ -607,8 +612,8 @@

if config["musicbrainz"]["genres"]:
sources = [
release["release-group"].get("genre-list", []),
release.get("genre-list", []),
release["release-group"].get("tag-list", []),
release.get("tag-list", []),
]
genres: Counter[str] = Counter()
for source in sources:
Expand Down Expand Up @@ -757,7 +762,7 @@


def _find_actual_release_from_pseudo_release(
pseudo_rel: dict,

Check failure on line 765 in beets/autotag/mb.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Missing type parameters for generic type "dict"
) -> dict | None:
try:
relations = pseudo_rel["release"]["release-relation-list"]
Expand Down
Loading