diff --git a/maloja/server.py b/maloja/server.py index 1451717..adece68 100755 --- a/maloja/server.py +++ b/maloja/server.py @@ -239,7 +239,10 @@ def static_html(name): lc["filterkeys"], lc["limitkeys"], lc["delimitkeys"], lc["amountkeys"], lc["specialkeys"] = uri_to_internal(keys) template = jinja_environment.get_template(name + '.jinja') - res = template.render(**LOCAL_CONTEXT) + try: + res = template.render(**LOCAL_CONTEXT) + except ValueError as e: + abort(404,"Entity does not exist") if settings.get_settings("DEV_MODE"): jinja_environment.cache.clear() diff --git a/scrobblers/chromium/background.js b/scrobblers/chromium/background.js index 11d297b..dcda636 100644 --- a/scrobblers/chromium/background.js +++ b/scrobblers/chromium/background.js @@ -1,5 +1,4 @@ - chrome.tabs.onUpdated.addListener(onTabUpdated); chrome.tabs.onRemoved.addListener(onTabRemoved); //chrome.tabs.onActivated.addListener(onTabChanged); @@ -303,21 +302,25 @@ class Controller { function scrobble(artist,title,seconds,secondsago=0) { console.log("Scrobbling " + artist + " - " + title + "; " + seconds + " seconds playtime, " + secondsago + " seconds ago") - var artiststring = encodeURIComponent(artist) - var titlestring = encodeURIComponent(title) var d = new Date() var time = Math.floor(d.getTime()/1000) - secondsago //console.log("Time: " + time) - var requestbody = "artist=" + artiststring + "&title=" + titlestring + "&duration=" + seconds + "&time=" + time - chrome.storage.local.get("apikey",function(result) { - APIKEY = result["apikey"] - chrome.storage.local.get("serverurl",function(result) { - URL = result["serverurl"] - var xhttp = new XMLHttpRequest(); - xhttp.open("POST",URL + "/api/newscrobble",true); - xhttp.send(requestbody + "&key=" + APIKEY) - //console.log("Sent: " + requestbody) - }); + var payload = { + "artist":artist, + "title":title, + "duration":seconds, + "time":time + } + + chrome.storage.local.get(["serverurl","apikey"],function(result) { + payload["key"] = result["apikey"]; + var xhttp = new XMLHttpRequest(); + xhttp.open("POST",result["serverurl"] + "/apis/mlj_1/newscrobble",true); + xhttp.setRequestHeader("Content-Type", "application/json"); + //xhttp.send(requestbody + "&key=" + APIKEY) + var body = JSON.stringify(payload); + xhttp.send(body) + //console.log("Sent: " + body) }); diff --git a/scrobblers/chromium/manifest.json b/scrobblers/chromium/manifest.json index 16a5ba1..7b9fbde 100644 --- a/scrobblers/chromium/manifest.json +++ b/scrobblers/chromium/manifest.json @@ -3,8 +3,8 @@ "version": "1.6", "description": "Scrobbles tracks from various sites to your Maloja server", "manifest_version": 2, - "permissions": ["activeTab", - "declarativeContent", + "permissions": [ + "activeTab", "tabs", "storage", "http://*/", diff --git a/scrobblers/maloja-scrobbler.zip b/scrobblers/maloja-scrobbler.zip index 6db390d..ccc7eb1 100644 Binary files a/scrobblers/maloja-scrobbler.zip and b/scrobblers/maloja-scrobbler.zip differ