music-assistant / hass-music-assistant

Turn your Home Assistant instance into a jukebox, hassle free streaming of your favorite media to Home Assistant media players.
Apache License 2.0
1.35k stars 50 forks source link

Use track artist for missing album artist doesn't appear to work correctly #2697

Closed doctorgaul closed 2 months ago

doctorgaul commented 2 months ago

What version of Music Assistant has the issue?

2.1.0

What version of the Home Assistant Integration have you got installed?

2024.6.2 Issue still present with 2024.7.1.b0

Have you tried everything in the Troubleshooting FAQ and reviewed the Open and Closed Issues and Discussions to resolve this yourself?

The problem

Adding files to queue by searching for artist name also adds files from irrelevant artists. It seems like this problem appeared with Music Assistant 2.0.0

How to reproduce

Using the "Music Assistant: Play Media (advanced)" function in an automation, I will write an artist name (e.g., "Dave Brubeck") in the "Media ID(s)" section, and select "Artist" in the "Media type" section. The resulting playlist includes files from the relevant artist, but also many unrelated files.

For example, searching for "Dave Brubeck" also returns files from Moby, Gorillaz, and Imagine Dragons, among others. Searching for artist "Fatboy Slim" also returns files from Rob Zombie, Rockapella, and Rocky Horror Picture Show, among others.

The same problem occurs if I click into the Music Assistant web interface, use the "Search" tab to search for the artist name, and then select Play Now, Play Next, Add to Queue, etc.

Clicking into the "Artist" tab, filtering for artist name, and then clicking into the list of files by that artist also shows the extraneous files. E.g., clicking into the artist "Fatboy Slim" shows tracks from Rob Zombie, Rockapella, and Rocky Horror Picture Show, among others.

It seems like this problem appeared with Music Assistant 2.0.0

Music Providers

Local NAS containing MP3 files

Player Providers

PiCorePlayer, Music Assistant app on Windows

Full log output

music-assistant.log

Additional information

No response

What version of Home Assistant Core are your running

2024.7.3

What type of installation are you running?

Home Assistant OS

On what type of hardware are you running?

Generic x86-64 (e.g. Intel NUC)

OzGav commented 2 months ago

Sounds like a tagging problem. You have ticked the box saying you have reviewed the troubleshooting page but you haven't attached the logs.

doctorgaul commented 2 months ago

Oops. log added! Thanks for that.

I've checked the ID3 tagging on these files and the issue only appears in Music Assistant. When I search on the artist value, e.g., "Fatboy Slim" in Media Monkey, it returns the right results. When I browse to the file location on my network drive and look at the file details for the erroneous search results, there's no indication that they contain the searched term at all, in any of the metadata.

Is it possible Music Assistant's database somehow got corrupted during the update process? Is there a file I can delete somewhere to force MA to rebuild from scratch?

OzGav commented 2 months ago

If you just look at the log it is full of errors likely due to tagging. https://music-assistant.io/music-providers/filesystem/#tagging-files

doctorgaul commented 2 months ago

I'm aware that it's behaving like a tagging issue, but can you explain what specifically makes you think it's actually a tagging issue? As I said, I've looked at the ID3 data for multiple erroneous search results, and none of the metadata fields contain the term I'm searching for in MA. Further, these are files that have been in my library for years and worked fine with multiple different music programs. They were working fine with MA as well, until the most recent round of updates.

OzGav commented 2 months ago

Looking at the tags with a viewer is only useful if you know what you are looking for. MA builds a database when it parses the tracks. In the case you are describing that often occurs when there is no album artist and you have "Use various artists" selected as the fallback option in the settings. Thus a whole bunch of albums will get grouped together. It could also be folder structure. In either case you should follow the guidance in the docs and get rid of all those errors in the logs and then we can see if there is an actual bug in there.

doctorgaul commented 2 months ago

In the case you are describing that often occurs when there is no album artist and you have "Use various artists" selected as the fallback option in the settings. Thus a whole bunch of albums will get grouped together. It could also be folder structure.

I believe you're talking about this setting, yes? As you can see, it's set to use track artist, not "various artists" or the folder name:

track 7

you should follow the guidance in the docs and get rid of all those errors in the logs and then we can see if there is an actual bug in there.

Which would be what, exactly? The errors in the logs don't say anything about ID3 tags. I see two kinds, 'NoneType' object has no attribute 'unique_file_ids' and 2024-07-28 20:55:45.783 ERROR (MainThread) [music_assistant.providers.filesystem_smb] Error processing _[file path]_ - Unable to retrieve info for /tmp/filesystem_smb--qWpyTpcb/_[file path]_: Invalid argument. I don't know what the first one means, but the second looks like a simple file not found error, yes?

Here are some screenshots to show more clearly exactly what the problem looks like. I click into artist Fatboy Slim:

track

The listing for artist Fatboy Slim includes (among other erroneous results) a track from Rob Zombie:

track 2

Clicking into that Rob Zombie track does not show "Fatboy Slim" as an artist value:

track 3

Looking at the file properties in Windows does not show anything even similar to "Fatboy Slim" anywhere in the metadata:

track 4

Neither does Winamp:

track 5

Neither does Media Monkey:

track 6

And I want to emphasize again - this is impacting Home Assistant automations that were working fine on prior versions of the software. The exact same automations are playing the exact same files from the exact same NAS on the exact same devices using the exact same installation of Home Assistant. This worked fine before, and now it does not. I can't imagine how the issue could possibly be the actual file tagging.

OzGav commented 2 months ago

Showing what other software has in the tags is irrelevant unfortunately and the tag values you are showing are a tiny fraction of what MA is looking for. If the MusicBrainz unique identifiers are missing then MA will do its best to work out what should go in the database based on the folder structure and track name. Please understand that people who have followed the docs closely do not have these problems which is why I am asking you to properly tag your files and then we can look at it further. I can understand you may not want to do that but then we can't help further as that is what MA requires to work well. Here is an example of a properly tagged track. image

OzGav commented 2 months ago

Its also possible your path name is causing issues. Multiple exclamation marks and mutiple levels below the share level before reaching the artist share are not normal

doctorgaul commented 2 months ago

Its also possible your path name is causing issues. Multiple exclamation marks and mutiple levels below the share level before reaching the artist share are not normal

It's a messy data set that I'm consolidating and organizing in pieces. But I feel like this bears repeating:

this is impacting Home Assistant automations that were working fine on prior versions of the software. The exact same automations are playing the exact same files from the exact same NAS on the exact same devices using the exact same installation of Home Assistant. This worked fine before, and now it does not. I can't imagine how the issue could possibly be the actual file tagging.

Has something changed in how MA interacts with tagging? Eg, did searching for an Artist value previously target only the actual Artist field, and now it checks Album Artist as well? Do you have any suggestions for software I could use to look at the full metadata as shown in your screenshot? Would it be helpful to post a raw MP3 file as an example?

As you can probably tell, I'm by no means a tech professional, so I really appreciate you taking the time to help me figure this out. When I have some more time on my hands, I'll try updating some of the erroneous search results using MusicBrainz Picard as a test and let you know what I find.

OzGav commented 2 months ago

Actually I just noticed you are using an old version of the Integration. That could be causing the problem.

My screenshot is from Picard.

OzGav commented 2 months ago

Checking in how you are going with further fault finding?

doctorgaul commented 2 months ago

I think the issue is that MA isn't properly using the Artist field where Album Artist is missing. The false hits were all missing Album Artist values, and updating the Album Artist field for those files caused them to stop appearing in unrelated searches.

Any thoughts on how to get MA to properly use Artist where Album Artist is missing? A way to force it to rebuild its database or whatever?

OzGav commented 2 months ago

If the album artist field is missing then MA deals with that as selected in the settings for the file system provider

doctorgaul commented 2 months ago

I am aware that's how it's intended to work, but that is not what is currently happening. I have "Use Track Artist" selected, but I'm still encountering this issue.

352899580-d4f4541b-f291-4d8f-a289-e4d4dfba616f

OzGav commented 2 months ago

OK I will change the title and this will get looked at in due course

OzGav commented 2 months ago

Did you change the album artist setting after the tracks were imported into the database though?

doctorgaul commented 2 months ago

No, I've had that setting the same way since I initially installed MA.

When I first installed it, I recall seeing something in the logs that looked like it was scanning all my files one by one for Album Artist info. Something like "[File path] has no Album Artist, using Artist instead," over and over again for thousands of files. Perhaps it built an index during that process, and there's something wrong with it now? That's my best layman's guess.

Let me know if there's any other info or testing that would be useful. Thanks again for the help!

OzGav commented 2 months ago

It doesn't seem like you had that setting from the start though. It looks like the default was used "various artists"; the usual result of that is exactly what it looks like in your intitial report (which I why I said as much in one of my initial replies). I can only assume you changed the setting sometime after. However, changing that setting doesn't cause everything to get rescanned. So I think everything is working as designed as I believe that those tracks above were likely scanned initially and the album artist was set as various artists which then results in those tracks appeariing in searches together as MA believes they are from the same artist. Now that you have fixed the album artists things have returned to as you expect.

So I think this can be closed as everything is working as expected when the album artist is set correctly. The docs are clear as they say

MA requires the Album Artist tag to be set.

If you feel that something else is not working correctly after having set the album artist correctly then let us know.

doctorgaul commented 2 months ago

I feel like this merits repeating again - everything was working fine until a couple of updates ago. If what you're describing was indeed the problem, then I would have been having trouble from the start. Something has changed.

doctorgaul commented 2 months ago

I believe that those tracks above were likely scanned initially and the album artist was set as various artists which then results in those tracks appeariing in searches together as MA believes they are from the same artist.

If this were the case, then every song without an Album Artist would return on a search for "various artists." They do not; I get like 20 or 30 results when I search for "various artists," none of which have been incorrect hits for searches on actual Artist values.

Further, searching for two different terms returns completely different sets of false hits. E.g., as I mentioned above, searching for "Fatboy Slim" returns incorrect results which include hits for "Rob Zombie." Searching for "Dave Brubeck" returns false hits, but none of them are from Rob Zombie. If the issue was that MA was treating all files without Album Artist values the same way, then I would expect to see all files without Album Artist values come back as results in every search that returns false hits.

And finally, if MA were treating all files without Album Artist values as having "Various Artists" populated in the Album Artist field, then I wouldn't be getting false hits when I search for other terms in the first place.

OzGav commented 2 months ago

The way MA builds the database when tags are missing is complex.

At the end of the day I understand that you have rectified the missing album artists and that has fixed the problem. So what is the problem you now believe needs to be fixed? Additionally, if a change in the code was made how could it be verified to fix an issue when there is no way to check that when the problem is no longer manifest?

doctorgaul commented 2 months ago

At the end of the day I understand that you have rectified the missing album artists and that has fixed the problem.

I may have given an erroneous impression - the problem is not resolved. I adjusted the Album Artist value for a handful of files as a troubleshooting step, and determined that yes, altering the Album Artist value altered the behavior I was seeing in MA. I still have tens of thousands of files without an Album Artist value, which were being handled properly previously and which are not being handled properly now.

So what is the problem you now believe needs to be fixed? Additionally, if a change in the code was made how could it be verified to fix an issue when there is no way to check that when the problem is no longer manifest?

The problem continues to be that MA is not properly using Artist values for files where Album Artist is missing. Happy to take any troubleshooting steps that you think would be informative.

OzGav commented 2 months ago

I think it would be helpful to do a clean install so you can definitely know that the setting was correct from the outset. You should also confirm that the folder structure conforms to the recommendation in the docs.

doctorgaul commented 2 months ago

I gave up. Rather than reinstalling MA from scratch and potentially breaking something, I instead used a combination of Mp3Tag and Media Monkey to clean up my Artist tagging, and then used TagScanner to automatically populate Artist into any blank Album Artist fields. Everything works fine.

It certainly seems like there was something that changed about the way MA indexes my music collection. I'm a little surprised uninstalling and reinstalling is the only way to force MA to rebuild its index from scratch (the way it did the first time I added the directory, when it spent a couple hours logging all the files without Album Artist info). It might be worth implementing some kind of "library reset" feature, if that's doable.

Thanks again for your help, and for your work on MA! Really value the work you folks are doing!

OzGav commented 2 months ago

Glad you have it working. Your idea is noted for future consideration.