music: handle null mediastore album name

Mostly a band-aid to make null album names correspond to a folder name
(the standard MediaStore behavior).
This commit is contained in:
Alexander Capehart 2024-07-05 17:32:39 -06:00
parent 294c558b93
commit 82a015c1e1
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47

View file

@ -283,7 +283,10 @@ private class MediaStoreExtractorImpl(
// the file is not actually in the root internal storage directory. We can't do
// anything to fix this, really. We also can't really filter it out, since how can we
// know when it corresponds to the folder and not, say, Low Roar's breakout album "0"?
rawSong.albumName = cursor.getString(albumIndex)
// Also, on some devices it's literally just null. To maintain behavior sanity just
// replicate the majority behavior described prior.
rawSong.albumName = cursor.getStringOrNull(albumIndex)
?: requireNotNull(rawSong.path?.name) { "Invalid raw: No path" }
// Android does not make a non-existent artist tag null, it instead fills it in
// as <unknown>, which makes absolutely no sense given how other columns default
// to null if they are not present. If this column is such, null it so that