lyarenei / jellyfin-plugin-listenbrainz

ListenBrainz plugin for Jellyfin.
MIT License
65 stars 2 forks source link

Favorite's not Syncing on Jellyfin 8.12 #58

Closed tuxfoo closed 6 months ago

tuxfoo commented 7 months ago

Selecting favorite in Jellyfin does not seem to work on 8.12 (I have not tried this plugin on earlier versions).

I tried selecting favorite on current playing song and one that was not playing and then playing it.

I also could not remove favorite/love from within Jellyfin.

I have syncing for favorites enabled and alternative mode disabled.

lyarenei commented 7 months ago

I did some quick testing and it appears to work just fine.

Are you perhaps expecing the sync to occur right away? If so, then that's not how the plugin does the syncing. The sync only happens after a listen submission is sent (and successful). This is because earlier versions of ListenBrainz API required MSID (MessyBrainz ID) to send recording feedback (love/hate) for a listen, but that was only obtainable only after the listen was accepted by the server. Nowadays the API supports MBID as well, so I guess this could be modified.

tuxfoo commented 7 months ago

I wait for the track to finish playing, I enabled logging for "Jellyfin.Plugin.ListenBrainz"

As you mentioned it seems to be related to MSID/MBID.

It seems to be failing to pick up the MSID from musicbrainz.

[2023-12-04 00:25:09.971 +13:00] [DBG] [57] Jellyfin.Plugin.ListenBrainz: Picking up playback stop event for item "I'm A Man You Don't Meet Every Day"
[2023-12-04 00:25:09.971 +13:00] [INF] [57] Jellyfin.Plugin.ListenBrainz: MusicBrainz integration is enabled, fetching metadata for track "I'm A Man You Don't Meet Every Day"
[2023-12-04 00:25:09.971 +13:00] [INF] [57] Jellyfin.Plugin.ListenBrainz: No additional metadata available for track "I'm A Man You Don't Meet Every Day": "One or more errors occurred. (Audio item does not have a track MBID)"
[2023-12-04 00:25:09.971 +13:00] [DBG] [57] Jellyfin.Plugin.ListenBrainz: No additional metadata available
System.AggregateException: One or more errors occurred. (Audio item does not have a track MBID)
 ---> System.ArgumentException: Audio item does not have a track MBID
   at Jellyfin.Plugin.ListenBrainz.Clients.MusicBrainzClient.GetAudioItemMetadata(Audio item)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at Jellyfin.Plugin.ListenBrainz.PluginImplementation.GetAdditionalMetadata(EventData data)
[2023-12-04 00:25:09.971 +13:00] [DBG] [57] Jellyfin.Plugin.ListenBrainz: Sending request ("d1350f3"):
Method: "POST"
URI: https://api.listenbrainz.org/1/submit-listens
Data: "{\"listen_type\":\"single\",\"payload\":[{\"listened_at\":1701602709,\"track_metadata\":{\"artist_name\":\"The Pogues\",\"track_name\":\"I'm A Man You Don't Meet Every Day\",\"release_name\":\"Rum, Sodomy & The Lash\",\"additional_info\":{\"track_number\":4,\"tags\":[],\"media_player\":\"Jellyfin\",\"submission_client\":\"ListenBrainz plugin for Jellyfin\",\"submission_client_version\":\"3.1.2.0\",\"duration_ms\":175000}}}]}"
[2023-12-04 00:25:09.972 +13:00] [INF] [57] Jellyfin.Plugin.ListenBrainz: Favorite sync for track "I'm A Man You Don't Meet Every Day" and user "tuxfoo" failed: "Fallback to send feedback using MSID is not implemented"
[2023-12-04 00:25:09.972 +13:00] [DBG] [57] Jellyfin.Plugin.ListenBrainz: Favorite sync failed
Jellyfin.Plugin.ListenBrainz.Exceptions.MetadataException: Fallback to send feedback using MSID is not implemented
   at Jellyfin.Plugin.ListenBrainz.PluginImplementation.SendFeedbackUsingMsid()
   at Jellyfin.Plugin.ListenBrainz.PluginImplementation.HandleFavoriteSync(EventData data, AudioItemMetadata metadata, UserConfig userConfig)
[2023-12-04 00:25:09.977 +13:00] [DBG] [25] Jellyfin.Plugin.ListenBrainz: Picking up user data save event for item "I'm A Man You Don't Meet Every Day"
[2023-12-04 00:25:09.978 +13:00] [DBG] [25] Jellyfin.Plugin.ListenBrainz: Dropping event - alternative mode is disabled
[2023-12-04 00:25:09.979 +13:00] [DBG] [57] Jellyfin.Plugin.ListenBrainz: Picking up playback stop event for item "I'm A Man You Don't Meet Every Day"
[2023-12-04 00:25:09.979 +13:00] [INF] [57] Jellyfin.Plugin.ListenBrainz: Listen submit conditions track "I'm A Man You Don't Meet Every Day" and user "tuxfoo" were not met: "Played 0% (== 0 ticks), but required 50% or 2400000000 ticks"
[2023-12-04 00:25:09.979 +13:00] [DBG] [57] Jellyfin.Plugin.ListenBrainz: Listen submit conditions were not met
Jellyfin.Plugin.ListenBrainz.Api.Exceptions.ListenBrainzException: Played 0% (== 0 ticks), but required 50% or 2400000000 ticks
   at Jellyfin.Plugin.ListenBrainz.Api.Resources.Limits.AssertSubmitConditions(Int64 playbackPosition, Int64 runtime)
   at Jellyfin.Plugin.ListenBrainz.PluginImplementation.OnPlaybackStop(Object sender, PlaybackStopEventArgs args)

All my Albums have a "MusicBrainz Release Group Id" and "MusicBrainz Album Id" but none of the tracks seems to have any of the "External IDs"; this seems odd to me. Are these meant to be updated by the musicbrainz plugin when the the album is identified and metadata updated?

lyarenei commented 7 months ago

Ah, I undestand now.

It seems to be failing to pick up the MSID from musicbrainz.

No, MSIDs come from ListenBrainz, not MusicBrainz. However, I totally forgot to reimplement the fallback to the MSID - I just implemented the MBID part of the feedback API when rewriting the plugin and so the requests are failing, because there is no track MBID available in your case. This can be seen in the logs:

[2023-12-04 00:25:09.972 +13:00] [INF] [57] Jellyfin.Plugin.ListenBrainz: Favorite sync for ... failed: "Fallback to send feedback using MSID is not implemented"

All my Albums have a "MusicBrainz Release Group Id" and "MusicBrainz Album Id" but none of the tracks seems to have any of the "External IDs"; this seems odd to me. Are these meant to be updated by the musicbrainz plugin when the the album is identified and metadata updated?

Actually, I have no idea. I tag all my music with Picard, so the metadata are directly saved to the files. Then Jellyfin just has to read them and pull additional metadata using the IDs and show them in the UI.

Looking briefly at the MusicBrainz plugin source, it looks like it has implemented providers for albums and artists. Not for tracks though. It only exposes them to the user, so you can view and edit them in the UI.

tuxfoo commented 7 months ago

No, MSIDs come from ListenBrainz, not MusicBrainz. However, I totally forgot to reimplement the fallback to the MSID - I just implemented the MBID part of the feedback API when rewriting the plugin and so the requests are failing, because there is no track MBID available in your case. This can be seen in the logs:

Thanks for clarifying.

All my Albums have a "MusicBrainz Release Group Id" and "MusicBrainz Album Id" but none of the tracks seems to have any of the "External IDs"; this seems odd to me. Are these meant to be updated by the musicbrainz plugin when the the album is identified and metadata updated?

Actually, I have no idea. I tag all my music with Picard, so the metadata are directly saved to the files. Then Jellyfin just has to read them and pull additional metadata using the IDs and show them in the UI.

Looking briefly at the MusicBrainz plugin source, it looks like it has implemented providers for albums and artists. Not for tracks though. It only exposes them to the user, so you can view and edit them in the UI.

That was my observation from looking at the settings, I rather avoid making changes to the original files, I might look for a way of adding these to the Jellyfin database or make a CR for the musicbrainz plugin to add this feature.

tuxfoo commented 7 months ago

As a work around I created a python script to get the MBID for every track add it to Jellyfin since Jellyfin does add the MBID for the albums. If I knew C# I would have just fixed Jellyfin.Plugin.MetaBrainz.Plugin and made PR.

EDIT: I thought I would share the script rather than keeping it to myself. https://github.com/tuxfoo/python-jellyfin-script/

Anyway, this is more an issue with the metabrainz plugin rather than this plugin but having a fallback is a good idea as not everything is listed on musicbrainz.

lyarenei commented 6 months ago

@tuxfoo Good to see you managed to work around the issue.

In the meantime I have implemented the MSID fallback, released in plugin version 3.2.0.0.