Commit f0cd387e by ‘chizw’

[+]url参数校验

1 parent f4db36c0
...@@ -84,6 +84,8 @@ def deal_worker(task_id: str): ...@@ -84,6 +84,8 @@ def deal_worker(task_id: str):
if output_data is not None: if output_data is not None:
return return
url = sql_res[0]["file_url"] url = sql_res[0]["file_url"]
if url == "" or len(url) < 1 or not url.startswith("http"):
return
log.info(f"Worker {task_id} is running... url:{url}") log.info(f"Worker {task_id} is running... url:{url}")
consuming_start_time = time.perf_counter() consuming_start_time = time.perf_counter()
# 解析音频 # 解析音频
......
...@@ -183,8 +183,21 @@ class UrlParam(BaseModel): ...@@ -183,8 +183,21 @@ class UrlParam(BaseModel):
async def create_url(param: UrlParam): async def create_url(param: UrlParam):
try: try:
log.info(f"funasr create_url api param:{param}") log.info(f"funasr create_url api param:{param}")
task_id = str(uuid.uuid1())
url = param.url url = param.url
if url is None:
return BaseResponse(
code=-1,
msg="error",
data="url is empty"
)
url.replace(" ", "")
if url == "" or len(url) < 1 or not url.startswith("http"):
return BaseResponse(
code=-1,
msg="error",
data="url format error"
)
task_id = str(uuid.uuid1())
res = funasr_db.insert_ali_asr_model_res(task_id, url) res = funasr_db.insert_ali_asr_model_res(task_id, url)
if res is None or (isinstance(res, bool) and res is False): if res is None or (isinstance(res, bool) and res is False):
return BaseResponse( return BaseResponse(
...@@ -223,7 +236,7 @@ def start_process(): ...@@ -223,7 +236,7 @@ def start_process():
if __name__ == "__main__": if __name__ == "__main__":
log.info("funasr main starting...") log.info("funasr main starting...")
start_kafka() start_process()
funasr_producer.send_wait_task() funasr_producer.send_wait_task()
save_path = "./audio/" save_path = "./audio/"
if os.path.exists(save_path): if os.path.exists(save_path):
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!