|
@@ -56,12 +56,13 @@ class VideoProcessor:
|
|
return f"{now.strftime('%Y%m%d%H%M%S')}{rand_num}"
|
|
return f"{now.strftime('%Y%m%d%H%M%S')}{rand_num}"
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
- def remove_files(cls, video_path_url):
|
|
|
|
|
|
+ def remove_files(cls, mark):
|
|
"""
|
|
"""
|
|
删除指定目录下的所有文件和子目录
|
|
删除指定目录下的所有文件和子目录
|
|
"""
|
|
"""
|
|
- if os.path.exists(video_path_url) and os.path.isdir(video_path_url):
|
|
|
|
- for root, dirs, files in os.walk(video_path_url):
|
|
|
|
|
|
+ path = config['PATHS']['VIDEO_PATH'] + mark + "/"
|
|
|
|
+ if os.path.exists(path) and os.path.isdir(path):
|
|
|
|
+ for root, dirs, files in os.walk(path):
|
|
for file in files:
|
|
for file in files:
|
|
file_path = os.path.join(root, file)
|
|
file_path = os.path.join(root, file)
|
|
os.remove(file_path)
|
|
os.remove(file_path)
|
|
@@ -108,7 +109,7 @@ class VideoProcessor:
|
|
)
|
|
)
|
|
Feishu.finish_bot(text, "https://open.feishu.cn/open-apis/bot/v2/hook/e7697dc6-5254-4411-8b59-3cd0742bf703",
|
|
Feishu.finish_bot(text, "https://open.feishu.cn/open-apis/bot/v2/hook/e7697dc6-5254-4411-8b59-3cd0742bf703",
|
|
"【 机器改造通知 】")
|
|
"【 机器改造通知 】")
|
|
- cls.remove_files(video_path_url)
|
|
|
|
|
|
+ cls.remove_files(mark)
|
|
return
|
|
return
|
|
Common.logger(mark).info(f"{name}的{task_mark}下的ID{url} 获取视频完成,共{len(data_list)}条")
|
|
Common.logger(mark).info(f"{name}的{task_mark}下的ID{url} 获取视频完成,共{len(data_list)}条")
|
|
for video in data_list:
|
|
for video in data_list:
|
|
@@ -153,13 +154,13 @@ class VideoProcessor:
|
|
Feishu.finish_bot(text,
|
|
Feishu.finish_bot(text,
|
|
"https://open.feishu.cn/open-apis/bot/v2/hook/e7697dc6-5254-4411-8b59-3cd0742bf703",
|
|
"https://open.feishu.cn/open-apis/bot/v2/hook/e7697dc6-5254-4411-8b59-3cd0742bf703",
|
|
"【 机器改造通知 】")
|
|
"【 机器改造通知 】")
|
|
- cls.remove_files(video_path_url)
|
|
|
|
|
|
+ cls.remove_files(mark)
|
|
continue
|
|
continue
|
|
if new_video_path:
|
|
if new_video_path:
|
|
if video_ending and video_ending != 'None':
|
|
if video_ending and video_ending != 'None':
|
|
new_video_path = cls.handle_video_ending(new_video_path, video_ending, old_title, pw_random_id, video_path_url, mark, task_mark, url, name, video_share, zm, voice)
|
|
new_video_path = cls.handle_video_ending(new_video_path, video_ending, old_title, pw_random_id, video_path_url, mark, task_mark, url, name, video_share, zm, voice)
|
|
if new_video_path == None:
|
|
if new_video_path == None:
|
|
- cls.remove_files(video_path_url)
|
|
|
|
|
|
+ cls.remove_files(mark)
|
|
continue
|
|
continue
|
|
else:
|
|
else:
|
|
if video_share and video_share != 'None':
|
|
if video_share and video_share != 'None':
|
|
@@ -179,7 +180,7 @@ class VideoProcessor:
|
|
Feishu.finish_bot(text,
|
|
Feishu.finish_bot(text,
|
|
"https://open.feishu.cn/open-apis/bot/v2/hook/e7697dc6-5254-4411-8b59-3cd0742bf703",
|
|
"https://open.feishu.cn/open-apis/bot/v2/hook/e7697dc6-5254-4411-8b59-3cd0742bf703",
|
|
"【 机器改造通知 】")
|
|
"【 机器改造通知 】")
|
|
- cls.remove_files(video_path_url)
|
|
|
|
|
|
+ cls.remove_files(mark)
|
|
continue
|
|
continue
|
|
# 上传视频和封面,并更新数据库
|
|
# 上传视频和封面,并更新数据库
|
|
code = cls.upload_video_and_thumbnail(new_video_path, cover, v_id, new_title, task_mark, name, piaoquan_id,
|
|
code = cls.upload_video_and_thumbnail(new_video_path, cover, v_id, new_title, task_mark, name, piaoquan_id,
|
|
@@ -308,10 +309,10 @@ class VideoProcessor:
|
|
Feishu.insert_columns("ILb4sa0LahddRktnRipcu2vQnLb", sheet, "ROWS", 1, 2)
|
|
Feishu.insert_columns("ILb4sa0LahddRktnRipcu2vQnLb", sheet, "ROWS", 1, 2)
|
|
time.sleep(0.5)
|
|
time.sleep(0.5)
|
|
Feishu.update_values("ILb4sa0LahddRktnRipcu2vQnLb", sheet, "A2:Z2", values)
|
|
Feishu.update_values("ILb4sa0LahddRktnRipcu2vQnLb", sheet, "A2:Z2", values)
|
|
- cls.remove_files(video_path_url)
|
|
|
|
|
|
+ cls.remove_files(mark)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
Common.logger(mark).info(f"{name}的{task_mark}任务处理失败:{e}")
|
|
Common.logger(mark).info(f"{name}的{task_mark}任务处理失败:{e}")
|
|
- cls.remove_files(video_path_url)
|
|
|
|
|
|
+ cls.remove_files(mark)
|
|
continue
|
|
continue
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
@@ -520,7 +521,7 @@ class VideoProcessor:
|
|
|
|
|
|
return code
|
|
return code
|
|
except Exception as e:
|
|
except Exception as e:
|
|
- cls.remove_files(video_path_url)
|
|
|
|
|
|
+ cls.remove_files(mark)
|
|
Common.logger("error").warning(f"{name}的{task_mark}上传视频和封面到OSS,并更新数据库失败:{e}\n")
|
|
Common.logger("error").warning(f"{name}的{task_mark}上传视频和封面到OSS,并更新数据库失败:{e}\n")
|
|
return
|
|
return
|
|
|
|
|