bum icon indicating copy to clipboard operation
bum copied to clipboard

Fails if song metadata does not contain an "album" property

Open Gadgetoid opened this issue 5 years ago • 4 comments

In some cases a downloaded, single song (in this case, Dark all Day by GUNSHIP grabbed from BandCamp) may not have an "album" associated with it.

This causes a hard fail where it's assumed "album" exists, for example in brainz.py:

data = mus.search_releases(artist=song["artist"],
                           release=song["album"],
                           limit=1)

This can be fixed by using "title" in lieu of "album", and this seems to correctly fetch the album art too:

artist = song.get("artist")
title = song.get("title")
album = song.get("album", title)
data = mus.search_releases(artist=artist,
                           release=album,
                           limit=1)

I'm happy to do a PR to fix this, but can anyone think of instances where this might fail?

Gadgetoid avatar Oct 01 '19 13:10 Gadgetoid

It might be worth running a series of tests on a large number of files.

dylanaraps avatar Oct 01 '19 13:10 dylanaraps

I'll have to find someone who actually has a music collection.

A short term approach might be to trap the exception that occurs when trying to pull a non-existent "album" value and fail with default art.

Gadgetoid avatar Oct 01 '19 13:10 Gadgetoid

That's probably a better solution as this is an album art display tool and singles do still usually contain the album field.

dylanaraps avatar Oct 01 '19 13:10 dylanaraps

I decided not to open a new issue, but the same bug occurs when the "artist" field is blank. I agree about the default art. I have a large music collection to run tests against, just FYI.

jallbrit avatar Nov 11 '19 19:11 jallbrit