owntone / owntone-server

Linux/FreeBSD DAAP (iTunes) and MPD audio server with support for AirPlay 1 and 2 speakers (multiroom), Apple Remote (and compatibles), Chromecast, Spotify and internet radio.
https://owntone.github.io/owntone-server
GNU General Public License v2.0
2.07k stars 236 forks source link

macOS Catalina Music App 1.0.6.10 shows wrong album art #1193

Closed maichai closed 3 years ago

maichai commented 3 years ago

For the forked-daapd library the Apple macOS Music app shows the wrong album art. Using the debug log and using Wireshark I can see that it does not seem to fetch any Album Art from the forked-daapd, but the Album Art shown belongs to title in the forked-daapd library. So I guessed it is cached somewhere. I renamed the iTunes/Album Art folder just in case it got jumbled up. That did not help, all looks the same.

Interestingly, the Apple iOS Remote app shows the correct album art, and using the debug log and using Wireshark I can see it fetch the album art from forked-daapd.

Does anyone have an idea why Music app is assigning the alum art wrongly and how to fix that? Where is it caching the album art, can this cache be flushed?

accuratecopy commented 3 years ago

Have you tried to delete Music Library.musiclibrary from the User/Music folder? Make a backup first.

maichai commented 3 years ago

I am not aware of any such file in my directories = { "/music/Music" } folder. There are just the artist folders containing the album folders. Also not in the /config folder.

AFAIK the album art is either embedded in the music files, and if not, forked-daapd fetches it online.

stefan1983 commented 3 years ago

I've got the same problem as mentioned in #1195

Have you tried to delete Music Library.musiclibrary from the User/Music folder? Make a backup first.

For me this didn't change anything, still not working correctly.

@maichai @accuratecopy Meant the file in you macOS Music folder:

image

maichai commented 3 years ago

The $HOME/Music/Music/Music Library "file" you showed is actually a folder that contains very small files, no album art or references to that. Renaming that folder does not help, a new one is created and the album art in the daapd library still is shown wrong.

Or you mean $HOME/Music/iTunes/iTunes Music Library.xml ? That contains only the podcast episode data. There is also iTunes Library.itl, a binary file, when renamed, nothing changes, and is not regenerated. Also there is a folder Album Artwork. I actually already renamed Album Artwork, but that did not change a thing. It also did not get regenerated.

maichai commented 3 years ago

I looked with slothand saw that AMPLibraryAgent keeps the $HOME/Music/Music folder open, also if you rename stuff. So actually it is this agent that manages the music library data, not the Music app itself. There is also $HOME/Library/Caches/com.apple.Music and .../com.apple.iTunes. Renaming them all and rebooting made Music app to as where the library is or whether it should create a new one. I did the latter, but the album art still was associated to the wrong albums. I therefore assume that the misassignment does not stem from old cached data. I also dug into the WebKit cache of the Music app, but there seems to be album art that Music downloads from apples servers, probably for the Music store, but maybe even also for own stuff that is held by forked-daapd (which would be wrong, as I disabled Music app from fetching album art from the Internet).

To be honest ,I have no idea what is going on in Music app and it seems to be a lot more complex than I assumed.

I have no second macOS machine to validate the following hunch, but someone who does could check whether the album art for remote Music app libraries (as opposed to a forked-daapd library) on other macOS machines is shown properly in Music app.

stefan1983 commented 3 years ago

Anyone any update on this? Thanks!

accuratecopy commented 3 years ago

Yes, I've done some more research on this problem after dealing with it yesterday.

For information, I'm on a Mac mini M1 16GB RAM and 512GB SSD with MacOS Big Sur 11.3 beta 3 installed.

For the context, I have 2 CDs by the same artist with the same album name but not from the same year. After ripping them, I added them in the folder configured in forked-daapd. On the web interface, forked-daapd can see the 2 separate albums. On the Remote application on my iPhone, the 2 albums are well separated too. However on the MacOS Music application, the songs from the 2 albums are mixed in the same album. So to fix this problem, I changed the names of the 2 albums in the tags to differentiate them. In the Music application on MacOS, this resulted in a good separation between the 2 albums but the 2 albums have the cover of the first album, while elsewhere that it is in the Remote application on iOS or on the forked-daapd web interface everything is correct.

So I started searching in the macOS system files and started using the Activity Monitor to understand how the album artwork was cached in the Music application. I found that in the "User"/Music/Music/Music Library/Music Library.musiclibrary folders, there were not necessarily references to album art. Then in "User"/Library/Caches/com.apple.Music, there are cache files for the Music application, but nothing that solved my problem of bad album covers.

So as I kept searching, I realized that there was another component that was involved in caching album covers, and that was "AMPArtworkAgent". To continue, I looked for references to "AMPArtworkAgent".That's when I came across the "User"/Library/Containers/com.apple.AMPArtworkAgent folder. In this folder, there is a Data/Documents folder that contains :

I made a backup of all these files, then I deleted all this + the cache files in the com.apple.Music folder + the MusicLibrary.musiclibrary file. I restarted my Mac mini, then I reopened the Music application, there was nothing left, I waited for all the albums to be cached again and it worked!

Don't necessarily take this as the ultimate solution, if someone wants to try an alternative solution and share their experience with us, or try to understand exactly how album cover caching works, I'd love to hear what they have to say.

In the meantime, I hope this will help some of you, knowing that I'm not an isolated case.

maichai commented 3 years ago

@accuratecopy thanks for investigating this, it worked for me. You actually merely need to remove $HOME/Library/Containers/com.apple.AMPArtworkAgent/Data/Documents/artwork* and restart macOS.

stefan1983 commented 2 years ago

This still happens on a regular basis. Will there be a further investigation to find a good solution for wrong album covers?