rogerxavier commited on
Commit
90cd972
1 Parent(s): 66a66a5

Update api.py

Browse files
Files changed (1) hide show
  1. api.py +6 -6
api.py CHANGED
@@ -109,7 +109,7 @@ async def execute_py_file(file_name: str,background_tasks: BackgroundTasks):
109
  @app.get("/execute_all_task")
110
  async def execute_all_task(background_tasks: BackgroundTasks, bili_meta_data,file_list: List[str] = Query(["0filterImage","1removeMask", "2magiDialogCut", "3mergeDialogToVideo"]),
111
  mp4_out_file: str = 'mp4_out/output.mp4',
112
- allow_submit: bool = False, cover_url: str = ''
113
  ):
114
  #cover_url因为本地上传有协程问题,所以采用cover_url然后转换为Picture类型即可->bilibili_api.utls.picture.Picture.from_url(str)->str
115
  print("获取到的用户bili_meta_data是:", bili_meta_data)
@@ -118,10 +118,10 @@ async def execute_all_task(background_tasks: BackgroundTasks, bili_meta_data,fil
118
  print("获取到的file_list是",file_list)
119
  print("获取到的allow_submit是",allow_submit)
120
 
121
- background_tasks.add_task(process_tasks_and_upload, file_list, bili_meta_data, cover_url,allow_submit,background_tasks)
122
  return {"message": "提交成功"}
123
 
124
- def process_tasks_and_upload(file_list, bili_meta_data, cover_url,allow_submit,background_tasks):
125
  tasks = []
126
  for file_name in file_list:
127
  tasks.append(file_executer(file_name))
@@ -129,7 +129,7 @@ def process_tasks_and_upload(file_list, bili_meta_data, cover_url,allow_submit,
129
  if allow_submit:
130
  #因为采用cover_url上传,所以不需要读取内容然后保存本地->这样也会引起协程问题
131
  print("bili的提交进程进行加入后台任务")
132
- background_tasks.add_task(upload_video,bili_meta_data, cover_url)
133
  ##尝试能立刻返回的
134
 
135
 
@@ -156,7 +156,7 @@ def returnRandomSubscribeUrl(background_tasks: BackgroundTasks)->str:
156
 
157
 
158
 
159
- async def upload_video(meta:dict,cover_url:str):
160
  credential = Credential(sessdata=sessdata,
161
  bili_jct=bili_jct,
162
  buvid3=buvid3)
@@ -204,7 +204,7 @@ def zero_pad(s, length):
204
 
205
  #如果默认的cover不能过审,那么随机选取无水印的manga1下面的随便一个作为cover重新上传
206
  @app.get("/upload_again")
207
- async def upload_again(meta:dict,cover_url:str):
208
  credential = Credential(sessdata=sessdata,
209
  bili_jct=bili_jct,
210
  buvid3=buvid3)
 
109
  @app.get("/execute_all_task")
110
  async def execute_all_task(background_tasks: BackgroundTasks, bili_meta_data,file_list: List[str] = Query(["0filterImage","1removeMask", "2magiDialogCut", "3mergeDialogToVideo"]),
111
  mp4_out_file: str = 'mp4_out/output.mp4',
112
+ allow_submit: bool = False
113
  ):
114
  #cover_url因为本地上传有协程问题,所以采用cover_url然后转换为Picture类型即可->bilibili_api.utls.picture.Picture.from_url(str)->str
115
  print("获取到的用户bili_meta_data是:", bili_meta_data)
 
118
  print("获取到的file_list是",file_list)
119
  print("获取到的allow_submit是",allow_submit)
120
 
121
+ background_tasks.add_task(process_tasks_and_upload, file_list, bili_meta_data, allow_submit,background_tasks)
122
  return {"message": "提交成功"}
123
 
124
+ def process_tasks_and_upload(file_list, bili_meta_data, allow_submit,background_tasks):
125
  tasks = []
126
  for file_name in file_list:
127
  tasks.append(file_executer(file_name))
 
129
  if allow_submit:
130
  #因为采用cover_url上传,所以不需要读取内容然后保存本地->这样也会引起协程问题
131
  print("bili的提交进程进行加入后台任务")
132
+ background_tasks.add_task(upload_video,bili_meta_data)
133
  ##尝试能立刻返回的
134
 
135
 
 
156
 
157
 
158
 
159
+ async def upload_video(meta:dict):
160
  credential = Credential(sessdata=sessdata,
161
  bili_jct=bili_jct,
162
  buvid3=buvid3)
 
204
 
205
  #如果默认的cover不能过审,那么随机选取无水印的manga1下面的随便一个作为cover重新上传
206
  @app.get("/upload_again")
207
+ async def upload_again(meta:dict):
208
  credential = Credential(sessdata=sessdata,
209
  bili_jct=bili_jct,
210
  buvid3=buvid3)