From 3838d0f8360ee8c86a4f5b17dd0b57a2eba451f2 Mon Sep 17 00:00:00 2001 From: Thomas Price <23259503+thprice@users.noreply.github.com> Date: Sun, 22 Dec 2024 10:44:45 +0100 Subject: [PATCH] audioscrobbler_legacy: VLC compatibility The API specs on https://web.archive.org/web/20190531021725/https://www.last.fm/api/submissions have a 32 char session key and the port number in the response. VLC's audioscrobbler functionality expects this and does not work otherwise. --- maloja/apis/audioscrobbler_legacy.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/maloja/apis/audioscrobbler_legacy.py b/maloja/apis/audioscrobbler_legacy.py index 7f031231..7581478d 100644 --- a/maloja/apis/audioscrobbler_legacy.py +++ b/maloja/apis/audioscrobbler_legacy.py @@ -46,6 +46,9 @@ def handshake(self,pathnodes,keys): key = apikeystore[client] if self.check_token(auth,key,timestamp): sessionkey = self.generate_key(client) + if ':' not in host: + port = 80 if protocol == 'http' else 443 + host = f"{host}:{port}" return 200, ( "OK\n" f"{sessionkey}\n" @@ -109,7 +112,7 @@ def generate_key(self,client): str( random.choice( list(range(10)) + list("abcdefghijklmnopqrstuvwxyz") + - list("ABCDEFGHIJKLMNOPQRSTUVWXYZ"))) for _ in range(64)) + list("ABCDEFGHIJKLMNOPQRSTUVWXYZ"))) for _ in range(32)) self.mobile_sessions[key] = client return key