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: Fetch Artist info for redirected MBIDs #3093

Merged
merged 1 commit into from
Jan 8, 2025
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
8 changes: 5 additions & 3 deletions listenbrainz/db/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def load_artists_from_mbids_with_redirects(mb_curs, mbids: Iterable[str]) -> lis
JOIN mbids m
ON a.gid = m.gid::UUID
"""
results = execute_values(mb_curs, query, [(mbid,) for mbid in mbids], fetch=True)
results = execute_values(mb_curs, query, [(mbid,) for mbid in redirected_mbids], fetch=True)
metadata_idx = {row["artist_mbid"]: row for row in results}

# Finally collate all the results, ensuring that we have one entry with original_recording_mbid for each input
Expand All @@ -32,15 +32,17 @@ def load_artists_from_mbids_with_redirects(mb_curs, mbids: Iterable[str]) -> lis
redirected_mbid = index.get(mbid, mbid)
if redirected_mbid not in metadata_idx:
item = {
"artist_mbid": mbid,
"artist_mbid": redirected_mbid,
"name": None,
"comment": None,
"type": None,
"gender": None
"gender": None,
"original_artist_mbid": mbid
}
else:
data = metadata_idx[redirected_mbid]
item = dict(data)
item["original_artist_mbid"] = mbid

output.append(item)

Expand Down
2 changes: 1 addition & 1 deletion listenbrainz/db/similarity.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,6 @@ def get_artists(mb_curs, ts_curs, mbids, algorithm, count):

metadata = load_artists_from_mbids_with_redirects(mb_curs, similar_mbids)
for item in metadata:
item["score"] = score_idx.get(item["artist_mbid"])
item["score"] = score_idx.get(item["original_artist_mbid"])
item["reference_mbid"] = mbid_idx.get(item["artist_mbid"])
return metadata
Loading