API change! /api/generate/{recid}
This commit is contained in:
parent
775d618315
commit
d43e655181
2 changed files with 6 additions and 8 deletions
|
@ -137,10 +137,10 @@ class GenerateResponse(BaseModel):
|
|||
status: str
|
||||
message: str
|
||||
|
||||
@app.post("/api/generate")
|
||||
async def generate(req: GenerateInfo, response: Response, background_tasks: BackgroundTasks):
|
||||
@app.post("/api/generate/{recid}")
|
||||
async def generate(recid: int, response: Response, background_tasks: BackgroundTasks):
|
||||
# prendiamo la rec in causa
|
||||
rec = db._search(_id=req.id)[0]
|
||||
rec = db._search(_id=recid)[0]
|
||||
if rec.ready:
|
||||
return {
|
||||
"status": "ready",
|
||||
|
@ -183,7 +183,7 @@ async def generate(req: GenerateInfo, response: Response, background_tasks: Back
|
|||
db.get_session(rec).commit()
|
||||
background_tasks.add_task(
|
||||
generate_mp3,
|
||||
db_id=req.id,
|
||||
db_id=recid,
|
||||
start=rec.starttime,
|
||||
end=rec.endtime,
|
||||
outfile=os.path.join(get_config()["AUDIO_OUTPUT"], rec.filename),
|
||||
|
@ -193,7 +193,7 @@ async def generate(req: GenerateInfo, response: Response, background_tasks: Back
|
|||
"extra_tags": get_config()["TAG_EXTRA"],
|
||||
},
|
||||
)
|
||||
logger.debug("SUBMITTED: %d" % req.id)
|
||||
logger.debug("SUBMITTED: %d" % recid)
|
||||
return rec_msg(
|
||||
"Aggiornamento completato!",
|
||||
job_id=rec.id,
|
||||
|
|
|
@ -56,11 +56,9 @@ var RecAPI = {
|
|||
})
|
||||
},
|
||||
generate: function (rec) {
|
||||
return $.ajax('/api/generate', {
|
||||
return $.ajax('/api/generate/' + rec.id, {
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({ id: rec.id })
|
||||
})
|
||||
},
|
||||
get_archive: function () {
|
||||
|
|
Loading…
Reference in a new issue