添加util.flask;video_clip编辑逻辑

This commit is contained in:
2022-04-19 09:42:39 +08:00
parent 3f5df9df29
commit df20bab1ac
5 changed files with 105 additions and 18 deletions

View File

@ -3,6 +3,7 @@ import threading
from flask import Blueprint, jsonify
from model.Workflow import Workflow
from util.flask import not_found_json_response
from workflow.worker import do_workflow
from model import db
@ -18,18 +19,36 @@ def get_workflow_list():
@blueprint.get("/<int:workflow_id>")
def get_workflow_info(workflow_id):
workflow = Workflow.get(workflow_id)
if workflow is None:
return not_found_json_response(id=workflow_id)
return jsonify(workflow)
@blueprint.put("/<int:workflow_id>")
def modify_workflow_info(workflow_id):
workflow = Workflow.get(workflow_id)
if workflow is None:
return not_found_json_response(id=workflow_id)
return jsonify(workflow)
@blueprint.delete("/<int:workflow_id>")
def delete_workflow(workflow_id):
workflow = Workflow.get(workflow_id)
if workflow is not None:
db.session.delete(workflow)
db.session.commit()
return jsonify({
"id": workflow_id,
"old_data": workflow
})
@blueprint.post("/<int:workflow_id>/edit")
def start_editing(workflow_id):
workflow = Workflow.get(workflow_id)
if workflow is None:
response = jsonify({
"message": "Not Found"
})
response.status_code = 404
return response
return not_found_json_response(id=workflow_id)
workflow.editing = True
db.session.commit()
return jsonify(workflow.to_dict())
@ -39,11 +58,7 @@ def start_editing(workflow_id):
def done_editing(workflow_id):
workflow = Workflow.get(workflow_id)
if workflow is None:
response = jsonify({
"message": "Not Found"
})
response.status_code = 404
return response
return not_found_json_response(id=workflow_id)
workflow.editing = False
db.session.commit()
return jsonify(workflow.to_dict())
@ -53,11 +68,7 @@ def done_editing(workflow_id):
def do_workflow(workflow_id):
workflow = Workflow.get(workflow_id)
if workflow is None:
response = jsonify({
"message": "Not Found"
})
response.status_code = 404
return response
return not_found_json_response(id=workflow_id)
if len(workflow.video_clips) > 0 and len(workflow.danmaku_clips) > 0:
threading.Thread(target=do_workflow, args=(
workflow.video_clips[0].full_path,