badl/backend/__init__.py

27 lines
584 B
Python

from bottle import request, response, Bottle, HTTPResponse
from manager import Manager
from json import dumps
from pathlib import Path
manager = Manager()
app = Bottle()
@app.post("/video")
def add_videos():
nvlist = request.json["nvlist"].split()
manager.add_videos_by_number(nvlist)
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"])
manager.download(parent_dir)
return "OK"