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
|
status: str
|
||||||
message: str
|
message: str
|
||||||
|
|
||||||
@app.post("/api/generate")
|
@app.post("/api/generate/{recid}")
|
||||||
async def generate(req: GenerateInfo, response: Response, background_tasks: BackgroundTasks):
|
async def generate(recid: int, response: Response, background_tasks: BackgroundTasks):
|
||||||
# prendiamo la rec in causa
|
# prendiamo la rec in causa
|
||||||
rec = db._search(_id=req.id)[0]
|
rec = db._search(_id=recid)[0]
|
||||||
if rec.ready:
|
if rec.ready:
|
||||||
return {
|
return {
|
||||||
"status": "ready",
|
"status": "ready",
|
||||||
|
@ -183,7 +183,7 @@ async def generate(req: GenerateInfo, response: Response, background_tasks: Back
|
||||||
db.get_session(rec).commit()
|
db.get_session(rec).commit()
|
||||||
background_tasks.add_task(
|
background_tasks.add_task(
|
||||||
generate_mp3,
|
generate_mp3,
|
||||||
db_id=req.id,
|
db_id=recid,
|
||||||
start=rec.starttime,
|
start=rec.starttime,
|
||||||
end=rec.endtime,
|
end=rec.endtime,
|
||||||
outfile=os.path.join(get_config()["AUDIO_OUTPUT"], rec.filename),
|
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"],
|
"extra_tags": get_config()["TAG_EXTRA"],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
logger.debug("SUBMITTED: %d" % req.id)
|
logger.debug("SUBMITTED: %d" % recid)
|
||||||
return rec_msg(
|
return rec_msg(
|
||||||
"Aggiornamento completato!",
|
"Aggiornamento completato!",
|
||||||
job_id=rec.id,
|
job_id=rec.id,
|
||||||
|
|
|
@ -56,11 +56,9 @@ var RecAPI = {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
generate: function (rec) {
|
generate: function (rec) {
|
||||||
return $.ajax('/api/generate', {
|
return $.ajax('/api/generate/' + rec.id, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
contentType: 'application/json',
|
|
||||||
data: JSON.stringify({ id: rec.id })
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
get_archive: function () {
|
get_archive: function () {
|
||||||
|
|
Loading…
Reference in a new issue