From 9fb352cc6fe2bc41c56304e5ba941035fc1ac82d Mon Sep 17 00:00:00 2001 From: Krateng Date: Sat, 5 Sep 2020 16:59:25 +0200 Subject: [PATCH] Listenbrainz API now nods and smiles on 'playing_now' requests --- README.md | 4 +++- maloja/__pkginfo__.py | 2 +- maloja/apis/listenbrainz.py | 9 +++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ba4cea3..3b367c8 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,9 @@ API URL | Your Maloja URL followed by `/apis/listenbrainz` Username | Any name, doesn't matter (don't leave empty) Auth Token | Any of your API keys -These are tested with the Pano Scrobbler and the Simple Last.fm Scrobbler for Android. I'm thankful for any feedback whether other scrobblers work! +My recommendations are to use [Pano Scrobbler](https://github.com/kawaiiDango/pScrobbler) for Android and [Web Scrobbler](https://github.com/web-scrobbler/web-scrobbler) for the browser. Not that Web Scrobbler requires you to supply the full endpoint (`yoururl.tld/apis/listenbrainz/1/submit-listens`). + +I'm thankful for any feedback whether other scrobblers work! It is recommended to define a different API key for every scrobbler you use in `clients/authenticated_machines.tsv` in your Maloja folder. diff --git a/maloja/__pkginfo__.py b/maloja/__pkginfo__.py index aeb9e30..6c415b5 100644 --- a/maloja/__pkginfo__.py +++ b/maloja/__pkginfo__.py @@ -5,7 +5,7 @@ author = { "email":"maloja@krateng.dev", "github": "krateng" } -version = 2,9,5 +version = 2,9,6 versionstr = ".".join(str(n) for n in version) links = { "pypi":"malojaserver", diff --git a/maloja/apis/listenbrainz.py b/maloja/apis/listenbrainz.py index f7e3a16..2666e5c 100644 --- a/maloja/apis/listenbrainz.py +++ b/maloja/apis/listenbrainz.py @@ -49,11 +49,16 @@ class Listenbrainz(APIHandler): timestamp = int(listen["listened_at"]) except: timestamp = None + elif listentype == "playing_now": + pass except: raise MalformedJSONException() - self.scrobble(artiststr,titlestr,timestamp) - return 200,{"status":"ok"} + + if listentype == "playing_now": return 200,{"status":"ok"} + else: + self.scrobble(artiststr,titlestr,timestamp) + return 200,{"status":"ok"} def validate_token(self,pathnodes,keys): try: