jesseward / jellyfin-plugin-lastfm

LastFM plugin for the Jellyfin media system. Fork of the Emby Last.FM plug-in
179 stars 12 forks source link

Japanese characters cause plugin to throw Bad Request #14

Closed Lightning2X closed 4 years ago

Lightning2X commented 4 years ago

The plugin seems to crash whenever japanese characters are supplied in any tag. To replicate just get a song with foreign characters and the app will throw a bad request error as seen here: https://pastebin.com/ZdDw2umq. Tracks with normal english letters work fine however. My terminal and jellyfin both display japanese characters correctly. I am running the services on Ubuntu 19.04.

jesseward commented 4 years ago

Thanks for reporting.

Copying pastebin into GH issue.


   at Emby.Server.Implementations.HttpClientManager.HttpClientManager.EnsureSuccessStatusCode(HttpResponseMessage response, HttpRequestOptions options)
   at Emby.Server.Implementations.HttpClientManager.HttpClientManager.SendAsyncInternal(HttpRequestOptions options, HttpMethod httpMethod)
   at Emby.Server.Implementations.HttpClientManager.HttpClientManager.SendAsync(HttpRequestOptions options, HttpMethod httpMethod)
   at Jellyfin.Plugin.Lastfm.Api.BaseLastfmApiClient.Post[TRequest,TResponse](TRequest request)
   at Jellyfin.Plugin.Lastfm.Api.LastfmApiClient.Scrobble(Audio item, LastfmUser user)", name="NANI THE FUCK!!", track="NANI THE FUCK!!", artist="ななひら", album="ごーいん!", mbid=null```
jesseward commented 4 years ago

additional error messages

[2019-09-28 09:42:40.153 +00:00] [ERR] HTTP request failed with message: "{\"error\":13,\"message\":\"Invalid method signature supplied\"}"
[2019-09-28 09:42:40.166 +00:00] [ERR] Failed to send now playing for track: ex="MediaBrowser.Model.Net.HttpException: Bad Request
   at Emby.Server.Implementations.HttpClientManager.HttpClientManager.EnsureSuccessStatusCode(HttpResponseMessage response, HttpRequestOptions options)
   at Emby.Server.Implementations.HttpClientManager.HttpClientManager.SendAsyncInternal(HttpRequestOptions options, HttpMethod httpMethod)
   at Emby.Server.Implementations.HttpClientManager.HttpClientManager.SendAsync(HttpRequestOptions options, HttpMethod httpMethod)
   at Jellyfin.Plugin.Lastfm.Api.BaseLastfmApiClient.Post[TRequest,TResponse](TRequest request)
   at Jellyfin.Plugin.Lastfm.Api.LastfmApiClient.NowPlaying(Audio item, LastfmUser user)", name="NANI THE FUCK!!", track="NANI THE FUCK!!", artist="かめりあ", album="ごーいん", mbid=null
jesseward commented 4 years ago

regarding -> [2019-09-28 09:42:40.153 +00:00] [ERR] HTTP request failed with message: "{\"error\":13,\"message\":\"Invalid method signature supplied\"}" Some notes at https://www.last.fm/api/authspec#8 regarding the auth API spec . This point seems to stand out and is not adhered to Ensure your parameters are utf8 encoded. it could be a one-line fix.

diff --git a/Jellyfin.Plugin.Lastfm/Utils/Helpers.cs b/Jellyfin.Plugin.Lastfm/Utils/Helpers.cs
index 0bb4b25..9d619b5 100644
--- a/Jellyfin.Plugin.Lastfm/Utils/Helpers.cs
+++ b/Jellyfin.Plugin.Lastfm/Utils/Helpers.cs
@@ -16,7 +16,7 @@
             // Use input string to calculate MD5 hash
             var md5 = MD5.Create();

-            var inputBytes = Encoding.ASCII.GetBytes(input);
+            var inputBytes = Encoding.UTF8.GetBytes(input);
             var hashBytes = md5.ComputeHash(inputBytes);

             // Convert the byte array to hexadecimal string

After rebuilding, it seems to scrobble ok. Will test some more and submit a new build/version

[2019-09-28 10:12:57.493 +00:00] [INF] Setting range response values for "/media/かめりあ - ごーいん/NANI THE FUCK!!.mp3". RangeRequest: "bytes=0-" Content-Length: "774434", Content-Range: "bytes 0-774433/774434"
[2019-09-28 10:12:57.673 +00:00] [INF] last-fm data: [("api_key": "XXX"), ("method": "track.updateNowPlaying"), ("sk": "XX"), ("track": "NANI THE FUCK!!"), ("artist": "かめりあ"), ("duration": "27"), ("album": "ごーいん"), ("api_sig": "XX")]
[2019-09-28 10:12:58.091 +00:00] [INF] "jw76" is now playing artist="かめりあ", track="NANI THE FUCK!!", album="ごーいん"
[2019-09-28 10:13:24.817 +00:00] [INF] Playback stopped reported by app "Jellyfin Web" "10.3.7" playing "NANI THE FUCK!!". Stopped at "27252" ms
[2019-09-28 10:13:24.838 +00:00] [INF] last-fm data: [("api_key": "XX"), ("method": "track.scrobble"), ("sk": "XX"), ("track": "NANI THE FUCK!!"), ("artist": "かめりあ"), ("timestamp": "1569665605"), ("album": "ごーいん"), ("api_sig": "XX")]
[2019-09-28 10:13:24.933 +00:00] [INF] "jw76" played artist="かめりあ", track="NANI THE FUCK!!", album="ごーいん"
jesseward commented 4 years ago

Fixed in https://github.com/jesseward/jellyfin-plugin-lastfm/commit/b318f536114ef99ce3148673fb6f4a4348fe376e

Published https://github.com/jesseward/jellyfin-plugin-lastfm/releases/tag/v2.0.1 release