lyarenei / jellyfin-plugin-listenbrainz

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

Question: API requests failing #44

Closed yatriks closed 10 months ago

yatriks commented 10 months ago

Hi,

First of all, thanks for the excellent plugin.

I have Jellyfin (10.8.10) with the plugin (3.0.1.0) set up on my Raspberry PI.

However, I was noticing no data go through. I enabled debug logs for the plugin, and I see this everytime it tries to send a track (I enabled the alternative event for recognizing listens as it appears to be faster for debugging). Here's the logs I see:

[2023-08-11 19:04:50.418 -04:00] [DBG] Picking up user data save event for item "TRACK"
[2023-08-11 19:04:50.420 -04:00] [DBG] Invalid event
System.ArgumentException: This event is not a playback finished event
   at Jellyfin.Plugin.ListenBrainz.PluginImplementation.GetEventData(UserDataSaveEventArgs eventArgs)
   at Jellyfin.Plugin.ListenBrainz.PluginImplementation.OnUserDataSave(Object sender, UserDataSaveEventArgs args)
[2023-08-11 19:04:50.449 -04:00] [DBG] Picking up playback start event for item "TRACK"
[2023-08-11 19:04:50.450 -04:00] [INF] Checking required metadata and user configuration
[2023-08-11 19:04:50.452 -04:00] [INF] All checks passed, sending 'now playing' listen of track "TRACK" for user "yatrik"
[2023-08-11 19:04:50.453 -04:00] [INF] MusicBrainz integration is enabled, fetching metadata for track "TRACK"
[2023-08-11 19:04:50.455 -04:00] [INF] No additional metadata available for track "TRACK": "One or more errors occurred. (Audio item does not have a track MBID)"
[2023-08-11 19:04:50.456 -04:00] [DBG] 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-08-11 19:04:50.460 -04:00] [INF] Failed to send 'now playing' listen of track "TRACK" for user "yatrik": "The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters."
[2023-08-11 19:04:50.462 -04:00] [DBG] Send playing now failed
System.FormatException: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.
   at System.Convert.FromBase64CharPtr(Char* inputPtr, Int32 inputLength)
   at System.Convert.FromBase64String(String s)
   at Jellyfin.Plugin.ListenBrainz.Configuration.UserConfig.get_PlaintextApiToken()
   at Jellyfin.Plugin.ListenBrainz.Clients.ListenBrainzClient.SendNowPlaying(UserConfig config, Audio item, AudioItemMetadata audioMetadata)
   at Jellyfin.Plugin.ListenBrainz.PluginImplementation.OnPlaybackStart(Object sender, PlaybackProgressEventArgs args)
[2023-08-11 19:04:50.651 -04:00] [DBG] Picking up user data save event for item "TRACK"
[2023-08-11 19:04:50.653 -04:00] [DBG] Invalid event
System.ArgumentException: This event is not a playback finished event
   at Jellyfin.Plugin.ListenBrainz.PluginImplementation.GetEventData(UserDataSaveEventArgs eventArgs)
   at Jellyfin.Plugin.ListenBrainz.PluginImplementation.OnUserDataSave(Object sender, UserDataSaveEventArgs args)

From what I can tell, the token is saved correctly in my /var/lib/jellyfin/plugins/configurations/Jellyfin.Plugin.ListenBrainz.xml file. I have the MusicBrainz plugin version 10.8.10.0.

Not sure what's going wrong, can anyone help debug? Happy to do any additional diagnoses.

Thanks.

yatriks commented 10 months ago

I updated some of the metadata in my library, and that seems to have fixed the first part, i.e. this error is now gone:

---> 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)

However, this error persists:

[2023-08-11 19:04:50.462 -04:00] [DBG] Send playing now failed
System.FormatException: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.
   at System.Convert.FromBase64CharPtr(Char* inputPtr, Int32 inputLength)
   at System.Convert.FromBase64String(String s)
   at Jellyfin.Plugin.ListenBrainz.Configuration.UserConfig.get_PlaintextApiToken()
   at Jellyfin.Plugin.ListenBrainz.Clients.ListenBrainzClient.SendNowPlaying(UserConfig config, Audio item, AudioItemMetadata audioMetadata)
   at Jellyfin.Plugin.ListenBrainz.PluginImplementation.OnPlaybackStart(Object sender, PlaybackProgressEventArgs args)
[2023-08-11 19:04:50.651 -04:00] [DBG] Picking up user data save event for item "TRACK"
yatriks commented 10 months ago

I figured this out. The first error can simply be dealt with by disabling fetching additional metadata (though I'm sure there's a proper solution). The second, I got around with in a hacky way - I just stored the API token base64-encoded. That seemed to work. Not at all sure how to get to a fix, but hope this helps. Closing this out.

lyarenei commented 10 months ago

Hi @yatriks, sorry for not noticing this sooner. As for your errors:

The first error can simply be dealt with by disabling fetching additional metadata (though I'm sure there's a proper solution).

This is the proper solution. :) If you don't have track MBIDs in the song/track metadata, then the MusicBrainz integration part cannot fetch any data. Of course, you can also fix this by adding the Track MBID into metadata.

The integration is described in more detail here.

I got around with in a hacky way - I just stored the API token base64-encoded. That seemed to work. Not at all sure how to get to a fix...

This... I forgot to properly encode the token before saving. 🤦 The token should be indeed saved as a base64 string in the config. This should be fixed in version 3.0.2.0 now, thanks for reporting it!