You've already forked RadioPlayer
mirror of
https://github.com/radio95-rnt/RadioPlayer.git
synced 2026-02-26 21:53:54 +01:00
dirs?
This commit is contained in:
@@ -120,7 +120,6 @@ class Module(ActiveModifier):
|
||||
return {"status": "ok", "message": f"{len(songs_to_add)} songs added."}
|
||||
elif data.get("action") == "get_toplay":
|
||||
with self.file_lock:
|
||||
with open("/tmp/radioPlayer_toplay", "r") as f:
|
||||
return {"status": "ok", "data": [i.strip() for i in f.readlines() if i.strip()]}
|
||||
with open("/tmp/radioPlayer_toplay", "r") as f: return {"status": "ok", "data": [i.strip() for i in f.readlines() if i.strip()]}
|
||||
|
||||
activemod = Module()
|
||||
@@ -4,7 +4,9 @@ import threading, uuid, time
|
||||
from functools import partial
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
from socketserver import ThreadingMixIn
|
||||
from . import Track, PlayerModule
|
||||
from . import Track, PlayerModule, Path
|
||||
|
||||
MAIN_PATH_DIR = Path("/home/user/mixes")
|
||||
|
||||
class ThreadingHTTPServer(ThreadingMixIn, HTTPServer):
|
||||
"""Handle requests in a separate thread."""
|
||||
@@ -41,6 +43,10 @@ class APIHandler(BaseHTTPRequestHandler):
|
||||
else:
|
||||
rdata = {"error": "Request to active module timed out"}
|
||||
code = 504 # Gateway Timeout
|
||||
elif self.path == "/api/dirs":
|
||||
return {"base": str(MAIN_PATH_DIR), "files": [i.name for i in list(MAIN_PATH_DIR.iterdir())]}
|
||||
elif self.path.startswith("/api/dir/"):
|
||||
return [i.name for i in (MAIN_PATH_DIR / self.path.removeprefix("/api/dir/").removesuffix("/")).iterdir() if i.is_file()]
|
||||
else: rdata = {"error": "not found"}
|
||||
|
||||
self.send_response(code)
|
||||
|
||||
Reference in New Issue
Block a user