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.21k stars 44 forks source link

Duplicate tracks are listed twice if the favorite flag differs between music providers #2447

Closed madbrain76 closed 2 weeks ago

madbrain76 commented 2 weeks ago

What version of Music Assistant has the issue?

2.0.4

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

2024.5.1

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

The problem

If I have the same album in two providers,, but one a track is favorited in only one provider, it appears twice

How to reproduce

  1. choose an album that you have a local copy of, and also exists in a cloud provider . I chose "Harpsichord Music in the Grand Manner"
  2. add a "file system (network share)" music provider containing only this properly-tagged album
  3. add a cloud provider that contains the album, and has one track of this album favorited . I chose Qobuz, and track 8
  4. after some time, the album view shows two versions of track 8, one that is favorited, and another which is not image
  5. when playing the album through, track 8 plays twice
  6. the album is also listed as having 19 tracks on top, even though the last track is numbered 18
  7. unfavorite the Qobuz version of track 8 in MA
  8. the 2 versions of track 8 are still both listed
  9. go to settings and reload the file system provider
  10. go to the album view . The 2 versions of track 8 are still both listed
  11. go to settings and reload the qobuz provider
  12. go to the album view. The 2 versions of track 8 are still both listed
  13. open track 8 in the Qobuz app
  14. notice that it is still favorited
  15. now, favorite both versions of track 8 in MA
  16. go to settings, and reload both music providers
  17. go to the album view. The 2 versions of track 8 are still both listed
  18. go to settings, and delete the file system provider
  19. go to settings, and add the file system provider back
  20. go to album, and notice that the 2 versions of track 8 are still showing, but the one from the file system share is no longer favorited
  21. in the qobuz app, unfavorite track 8
  22. in MA settings, reload the qobuz provider
  23. synchronize the qobuz provider
  24. finally, only version of the track shows in the album view
  25. click the | menu and "show info" for track 8
  26. it only shows one provider, the file system provider
  27. the same is true for all other tracks in the album
  28. favorite track 8 in the album
  29. in the settings, synchronize both providers
  30. in the album view, only one version of track 8 shows
  31. open the qobuz app
  32. see that track 8 is not favorited
  33. in MA settings, delete the file system provider
  34. go to the album view
  35. observe that track 8 is no longer favorited
  36. favorite the track
  37. in MA settings, synchronize the Qobuz provider
  38. open the Qobuz app
  39. it still doesn't show track 8 as favorited
  40. kill the Qobuz app and reopen it
  41. it now shows track 8 as favorited

Music Providers

File system (network share) Qobuz

Player Providers

Chromecast

Full log output

log.txt

Additional information

I'm primarily concerned about what happens in steps 4/5/6 - two versions of the same track are shown, both play, and the album has the wrong number of tracks. I don't know how the conflicting favorite icon/state should be presented in the UI in this case, but I'm sure you can come up with a way, so I won't suggest one. This may be an edge case, but I don't think it will be that uncommon.

It took me a while to resolve the duplicates in the UI. I realized much too late that I needed to use "synchronize now" rather than "reload". The synchronization in MA doesn't happen automatically, or when manually reloading, and perhaps also not when deleting the provider. Even in Qobuz, it requires killing the app to trigger it. None of that was obvious.

Once the conflict was resolved, and I favorited a track, the favorite flag appears to have propagated only to one of the 2 music providers that contained the track, the file system provider, but not to the Qobuz provider, until I deleted the file system provider. That part may be deserving of its own separate issue, but I just found out about it.

What version of Home Assistant Core are your running

2024.6.2

What type of installation are you running?

Home Assistant OS

On what type of hardware are you running?

Windows

OzGav commented 2 weeks ago

Probably a duplicate of https://github.com/music-assistant/hass-music-assistant/issues/2319

madbrain76 commented 2 weeks ago

Probably a duplicate of #2319

Yes, they may well have the same root cause. But the Plex provider probably shouldn't be favoriting everything. Plex uses ratings rather than favorites. Perhaps the Plex provider, if it was under active development, could be tuned to handle the ratings, and translate them to MA favorites (or not). This should work 1-way (from Plex to MA) but probably not the other way.

Whereas the case where the favorite flag conflicts between the file system and a cloud music provider is not the fault of either provider, and probably somewhat more common. I know I have several of my favorite albums in both local & cloud (Qobuz), but I may not have favorited the exact same tracks/albums in both.

OzGav commented 2 weeks ago

The Plex idea is noted

You are misunderstanding the favourite flag though. It relates to the library not a specific provider. However, some providers do synchronise the favourite flag in both directions with the library but this depends on the provider. File system though has no concept of the favourite flag

madbrain76 commented 2 weeks ago

I read the doc on the FS provider earlier tonight, and did not learn about its lack or support for favorite. That is unfortunate. It would have saved me time to know this upfront. Perhaps there isn't a standard Metadata flag for favorite. That would certainly explain it. I use Jriver, which also uses star ratings, like Plex, but doesn't have a Music provider yet Maybe the FS provider could also read that ratings Metadata. For writing, it could set 5 stats perhaps.

Even if the FS provider is left untouched, it may be possible to have a favorite flag conflict between 2 cloud providers, so this problem could still show up.

OzGav commented 2 weeks ago

I need to clarify something that I wrote above because it is misleading.

The favourite flag in MA is just a filter for the MA library it actually has no effect on the streaming providers per se.

What does happen though is any item that is added to the MA LIBRARY is synced to the provider that the item was from. The provider library is called different things, Spotify calls it “Your Library., Tidal calls it “My collection” but Qobuz calls it “Favourites” I think which would cause confusion if that is true.

What also happens in MA is if you press the favourite heart then that, by necessity, adds the item to the library and it is that automatic action that causes the sync described above to occur.

Finally, you ask about conflicts with the streaming providers. This won’t occur. If you add provider A that has album Z in its library it will be added to the MA library. If you then add provider B (whether or not it also has album Z in its library) nothing will happen except the albums will be linked in the DB. Nothing will happen back at provider B if album Z was not in that providers library because a sync only occurs if the album is added to the MA library from that provider. You might say but I want that album to be added to provider B’s library and that functionality is up for discussion at a later time when a related backlog item gets actioned.

vhsdream commented 2 weeks ago

I subscribed to this issue because I was experiencing the same thing with my Plex library, and had a lot of the following in the logs:

2024-06-11 16:45:54.409 ERROR (MainThread) [music_assistant.providers.plex] ERROR: Forêt vierge has no userRating 2024-06-11 16:45:54.420 ERROR (MainThread) [music_assistant.providers.plex] ERROR: L’Âge d’or has no userRating 2024-06-11 16:45:54.430 ERROR (MainThread) [music_assistant.providers.plex] ERROR: Black Paradise has no userRating 2024-06-11 16:45:54.441 ERROR (MainThread) [music_assistant.providers.plex] ERROR: The Beach has no userRating

However after updating to the latest beta (2.1.0b4) I can say that this no longer happens, and it appears the duplication issue is resolved as well. #2307 too.

madbrain76 commented 2 weeks ago

@OzGav ,

Thanks for the explanation. Yes, Qobuz calls is "Favourites" if you select "English" as the language in the Windows app. Or "Favorites" if you select English (US)"

MA calls it "Favorites" whether you select "English (GB)" or "English".

Spelling aside, the common word was certainly part of the confusion. For edge cases, the behavior is not obvious, or what is obvious behavior depends on the beholder.

Thanks for the explanation about the lack of conflict between cloud providers.

I think if one unfavorites" an album/track from in MA, that should propagate to all the providers it exists in, assuming they support it. But there many edge cases, depending on the handling of the favorite flag at multiple providers, where things are unfavorited (in MA, or in the cloud providers apps), and in which order each provider is synchronized.

madbrain76 commented 2 weeks ago

I subscribed to this issue because I was experiencing the same thing with my Plex library, and had a lot of the following in the logs:

2024-06-11 16:45:54.409 ERROR (MainThread) [music_assistant.providers.plex] ERROR: Forêt vierge has no userRating 2024-06-11 16:45:54.420 ERROR (MainThread) [music_assistant.providers.plex] ERROR: L’Âge d’or has no userRating 2024-06-11 16:45:54.430 ERROR (MainThread) [music_assistant.providers.plex] ERROR: Black Paradise has no userRating 2024-06-11 16:45:54.441 ERROR (MainThread) [music_assistant.providers.plex] ERROR: The Beach has no userRating

However after updating to the latest beta (2.1.0b4) I can say that this no longer happens, and it appears the duplication issue is resolved as well. #2307 too.

Great that the issue with Plex is resolved - unfortunately, it's more complicated with the FS provider. I filed an RFE at https://github.com/orgs/music-assistant/discussions/2463 .

OzGav commented 2 weeks ago

As the original report here is being tracked in an earlier issue report I am closing this one.