zhangyong 4 ماه پیش
والد
کامیت
6e7ec2f797
1فایلهای تغییر یافته به همراه52 افزوده شده و 53 حذف شده
  1. 52 53
      video_rewriting/video_processor.py

+ 52 - 53
video_rewriting/video_processor.py

@@ -206,64 +206,63 @@ class VideoProcessor:
                     video_path = FFmpeg.video_crop(video_path, file_path, pw_random_id)
                 if gg_duration_total and gg_duration_total != 'None':  # 判断是否需要指定视频时长
                     video_path = FFmpeg.video_ggduration(video_path, file_path, pw_random_id,gg_duration_total)
-                if video_ending and video_ending != 'None':
-                    if video_ending == "AI片尾引导":
-                        pw_srt_text = GPT4oMini.get_ai_mini_pw(old_title)
-                        pw_url = TTS.get_pw_zm(pw_srt_text, voice)
-                        pw_mp3_path = TTS.download_mp3(pw_url, file_path, pw_random_id)
-                        pw_srt = TTS.getSrt(pw_url)
+                if video_ending == "AI片尾引导":
+                    pw_srt_text = GPT4oMini.get_ai_mini_pw(old_title)
+                    pw_url = TTS.get_pw_zm(pw_srt_text, voice)
+                    pw_mp3_path = TTS.download_mp3(pw_url, file_path, pw_random_id)
+                    pw_srt = TTS.getSrt(pw_url)
+                else:
+                    if ',' in video_ending:
+                        video_ending_list = video_ending.split(',')
                     else:
-                        if ',' in video_ending:
-                            video_ending_list = video_ending.split(',')
-                        else:
-                            video_ending_list = [video_ending]
-                        ending = random.choice(video_ending_list)
-                        pw_list = Material.get_pwsrt_data("summary", "DgX7vC", ending)  # 获取srt
-                        pw_id = pw_list["pw_id"]
-                        pw_srt = pw_list["pw_srt"]
-                        pw_url = PQ.get_pw_url(pw_id)
-                        pw_mp3_path = FFmpeg.get_video_mp3(pw_url, file_path, pw_random_id)
-                    if not pw_url:
-                        AliyunLogger.logging(channel_id, name, url, v_id, "获取片尾失败", "3002")
-                        continue
-                    jpg_path = FFmpeg.video_png(video_path, file_path, pw_random_id)  # 生成视频最后一帧jpg
-                    if not os.path.exists(jpg_path) or os.path.getsize(jpg_path) == 0:
-                        AliyunLogger.logging(channel_id, name, url, v_id, "片尾获取最后一帧失败", "3002")
-                        continue
-                    pw_path = FFmpeg.pw_video(jpg_path, file_path,  pw_srt, pw_random_id, pw_mp3_path)  # 生成片尾视频
-                    if not os.path.exists(pw_path) or os.path.getsize(pw_path) == 0:
-                        AliyunLogger.logging(channel_id, name, url, v_id, "生成片尾失败", "3002")
-                        text = (
-                            f"**通知类型**: 生成片尾失败\n"
-                            f"**负责人**: {name}\n"
-                            f"**渠道**: {channel_id}\n"
-                            f"**视频主页ID**: {url}\n"
-                            f"**视频Video_id**: {v_id}\n"
-                        )
-                        Feishu.finish_bot(text,
-                                          "https://open.feishu.cn/open-apis/bot/v2/hook/e7697dc6-5254-4411-8b59-3cd0742bf703",
-                                          "【 机器改造通知 】")
-                        continue
-                    video_path = FFmpeg.h_b_video(video_path, pw_path, file_path)
-                    video_path = FFmpeg.single_video(video_path, file_path, zm)
-                    if not os.path.exists(video_path) or os.path.getsize(video_path) == 0:
-                        AliyunLogger.logging(channel_id, name, url, v_id, "拼接失败", "3002")
-                        text = (
-                            f"**通知类型**: 视频改造失败\n"
-                            f"**负责人**: {name}\n"
-                            f"**渠道**: {channel_id}\n"
-                            f"**视频主页ID**: {url}\n"
-                            f"**视频Video_id**: {v_id}\n"
-                        )
-                        Feishu.finish_bot(text,
-                                          "https://open.feishu.cn/open-apis/bot/v2/hook/e7697dc6-5254-4411-8b59-3cd0742bf703",
-                                          "【 机器改造通知 】")
-                        continue
+                        video_ending_list = [video_ending]
+                    ending = random.choice(video_ending_list)
+                    pw_list = Material.get_pwsrt_data("summary", "DgX7vC", ending)  # 获取srt
+                    pw_id = pw_list["pw_id"]
+                    pw_srt = pw_list["pw_srt"]
+                    pw_url = PQ.get_pw_url(pw_id)
+                    pw_mp3_path = FFmpeg.get_video_mp3(pw_url, file_path, pw_random_id)
+                if not pw_url:
+                    AliyunLogger.logging(channel_id, name, url, v_id, "获取片尾失败", "3002")
+                    continue
+                jpg_path = FFmpeg.video_png(video_path, file_path, pw_random_id)  # 生成视频最后一帧jpg
+                if not os.path.exists(jpg_path) or os.path.getsize(jpg_path) == 0:
+                    AliyunLogger.logging(channel_id, name, url, v_id, "片尾获取最后一帧失败", "3002")
+                    continue
+                pw_path = FFmpeg.pw_video(jpg_path, file_path,  pw_srt, pw_random_id, pw_mp3_path)  # 生成片尾视频
+                if not os.path.exists(pw_path) or os.path.getsize(pw_path) == 0:
+                    AliyunLogger.logging(channel_id, name, url, v_id, "生成片尾失败", "3002")
+                    text = (
+                        f"**通知类型**: 生成片尾失败\n"
+                        f"**负责人**: {name}\n"
+                        f"**渠道**: {channel_id}\n"
+                        f"**视频主页ID**: {url}\n"
+                        f"**视频Video_id**: {v_id}\n"
+                    )
+                    Feishu.finish_bot(text,
+                                      "https://open.feishu.cn/open-apis/bot/v2/hook/e7697dc6-5254-4411-8b59-3cd0742bf703",
+                                      "【 机器改造通知 】")
+                    continue
+                video_path = FFmpeg.h_b_video(video_path, pw_path, file_path)
+                video_path = FFmpeg.single_video(video_path, file_path, zm)
+                if not os.path.exists(video_path) or os.path.getsize(video_path) == 0:
+                    AliyunLogger.logging(channel_id, name, url, v_id, "拼接失败", "3002")
+                    text = (
+                        f"**通知类型**: 视频改造失败\n"
+                        f"**负责人**: {name}\n"
+                        f"**渠道**: {channel_id}\n"
+                        f"**视频主页ID**: {url}\n"
+                        f"**视频Video_id**: {v_id}\n"
+                    )
+                    Feishu.finish_bot(text,
+                                      "https://open.feishu.cn/open-apis/bot/v2/hook/e7697dc6-5254-4411-8b59-3cd0742bf703",
+                                      "【 机器改造通知 】")
+                    continue
 
 
                 # 上传视频和封面,并更新数据库
                 code = cls.upload_video_and_thumbnail(video_path, cover, v_id, new_title, task_mark, name, piaoquan_id,
-                                               file_path, mark, channel_id, url, old_title, title, rule, video)
+                                                   file_path, mark, channel_id, url, old_title, rule, video)
                 # 更新已使用的视频号状态
                 pq_url = f'https://admin.piaoquantv.com/cms/post-detail/{code}/detail'  # 站内视频链接
                 if name == "单点视频":