You've already forked RadioPlayer
mirror of
https://github.com/radio95-rnt/RadioPlayer.git
synced 2026-02-27 06:03:52 +01:00
keep junk out
This commit is contained in:
@@ -121,6 +121,6 @@ class Module(ActiveModifier):
|
|||||||
elif data.get("action") == "get_toplay":
|
elif data.get("action") == "get_toplay":
|
||||||
with self.file_lock:
|
with self.file_lock:
|
||||||
with open("/tmp/radioPlayer_toplay", "r") as f:
|
with open("/tmp/radioPlayer_toplay", "r") as f:
|
||||||
return {"status": "ok", "data": f.readlines()}
|
return {"status": "ok", "data": [i.strip() for i in f.readlines() if i.strip()]}
|
||||||
|
|
||||||
activemod = Module()
|
activemod = Module()
|
||||||
@@ -28,13 +28,13 @@ class APIHandler(BaseHTTPRequestHandler):
|
|||||||
response_json = None
|
response_json = None
|
||||||
while time.monotonic() - start_time < 2:
|
while time.monotonic() - start_time < 2:
|
||||||
if id in self.data:
|
if id in self.data:
|
||||||
response_json = self.data.pop(id) # Read and remove the entry
|
response_json = self.data.pop(id)
|
||||||
break
|
break
|
||||||
time.sleep(0.05) # Wait briefly to avoid a busy loop
|
time.sleep(0.05)
|
||||||
if response_json:
|
if response_json:
|
||||||
try:
|
try:
|
||||||
rdata = response_json
|
rdata = response_json
|
||||||
if "error" in repr(rdata): code = 500 # Server error if module reported one
|
if "error" in repr(rdata): code = 500
|
||||||
except TypeError:
|
except TypeError:
|
||||||
rdata = {"error": "Invalid data format from module"}
|
rdata = {"error": "Invalid data format from module"}
|
||||||
code = 500
|
code = 500
|
||||||
|
|||||||
Reference in New Issue
Block a user