badl/backend/__init__.py

32 lines
672 B
Python
Raw Normal View History

2023-02-23 21:43:58 +08:00
from bottle import request, response, Bottle, HTTPResponse
2023-02-21 19:56:22 +08:00
from manager import Manager
from json import dumps
from pathlib import Path
manager = Manager()
app = Bottle()
@app.post("/video")
def add_videos():
2023-02-23 21:43:58 +08:00
nvlist = request.json["nvlist"].split()
manager.add_videos_by_number(nvlist)
2023-02-21 19:56:22 +08:00
return "OK"
@app.get("/progress")
def get_progress():
response.content_type = "application/json"
return dumps(manager.get_progress())
@app.post("/download")
def download():
parent_dir = Path(request.json["parent_dir"])
id = request.json["id"]
try:
manager.download(id, parent_dir)
return "OK"
except:
return "Not ready"