zhangyong 9 months ago
parent
commit
57d4e5aa8a
4 changed files with 60 additions and 10 deletions
  1. 13 2
      common/ffmpeg.py
  2. 2 2
      common/sql_help.py
  3. 34 0
      data_channel/sph_keyword.py
  4. 11 6
      video_rewriting/video_processor.py

+ 13 - 2
common/ffmpeg.py

@@ -302,8 +302,19 @@ class FFmpeg():
         ffmpeg_cmd.extend(FF_INPUT.split())
         ffmpeg_cmd.extend(FF_INPUT.split())
         ffmpeg_cmd.extend(["-filter_complex", f"{FF_SCALE}{FF_FILTER}concat=n={VIDEO_COUNTER}:v=1:a=1[v][a]",
         ffmpeg_cmd.extend(["-filter_complex", f"{FF_SCALE}{FF_FILTER}concat=n={VIDEO_COUNTER}:v=1:a=1[v][a]",
                            "-map", "[v]", "-map", "[a]", "-y", concatenate_videos_url])
                            "-map", "[v]", "-map", "[a]", "-y", concatenate_videos_url])
-        subprocess.run(ffmpeg_cmd)
-        return concatenate_videos_url
+        # subprocess.run(ffmpeg_cmd)
+        try:
+            result = subprocess.run(ffmpeg_cmd, capture_output=True, text=True)
+            if result.returncode != 0:
+                # 打印错误信息并返回 None
+                print("ffmpeg 错误信息:", result.stderr)
+                return None
+            else:
+                return concatenate_videos_url
+        except Exception as e:
+            # 捕获其他异常并返回 None
+            print("处理视频时出现异常:", e)
+            return None
 
 
     """
     """
     单个视频拼接
     单个视频拼接

+ 2 - 2
common/sql_help.py

@@ -182,7 +182,7 @@ class sqlCollect():
         """
         """
         获取视频号单点内容
         获取视频号单点内容
         """
         """
-        sql = f"""select video_id,title,author_id,author_name,cover_url,video_url,video_duration,from_user_id,from_user_name,from_group_id,from_group_name,source,wx_msg, is_encrypted, decode_key  from dandian_content where from_user_name = %s and has_used = 0 limit 2"""
+        sql = f"""select video_id,title,author_id,author_name,cover_url,video_url,video_duration,from_user_id,from_user_name,from_group_id,from_group_name,source,wx_msg, is_encrypted, decode_key  from dandian_content where from_user_name = %s and has_used = 0 ORDER BY create_timestamp DESC  limit 2"""
         data = AigcMysqlHelper.get_values(sql, (url))
         data = AigcMysqlHelper.get_values(sql, (url))
         return data
         return data
 
 
@@ -200,7 +200,7 @@ class sqlCollect():
     @classmethod
     @classmethod
     def update_shp_dd_vid_4(cls, vid):
     def update_shp_dd_vid_4(cls, vid):
         """
         """
-        视频号单点修改状态为2
+        视频号单点修改状态为4
         """
         """
         sql = f"""UPDATE dandian_content set has_used = 4 where video_id = '{vid}'"""
         sql = f"""UPDATE dandian_content set has_used = 4 where video_id = '{vid}'"""
         res = AigcMysqlHelper.update_values(
         res = AigcMysqlHelper.update_values(

+ 34 - 0
data_channel/sph_keyword.py

@@ -0,0 +1,34 @@
+import requests
+import json
+
+from common import Common, Feishu
+
+
+class KsKeyword:
+    @classmethod
+    def get_key_word(cls, keyword, task_mark, mark, channel_id, name, task):
+        url = "http://8.217.190.241:8888/crawler/wei_xin/shi_pin_hao/keyword"
+        list = []
+        payload = json.dumps({
+            "keyword": keyword,
+            "sort": "不限",
+            "cursor": ""
+        })
+        headers = {
+            'Content-Type': 'application/json'
+        }
+        try:
+            response = requests.request("POST", url, headers=headers, data=payload)
+            response = response.json()
+            code = response['code']
+            if code != 0:
+                Feishu.finish_bot(f"shi_pin_hao/keyword {response['msg']}",
+                                  "https://open.feishu.cn/open-apis/bot/v2/hook/575ca6a1-84b4-4a2f-983b-1d178e7b16eb",
+                                  "【视频号搜索接口使用提示】")
+                Common.logger("sph-key-word").info(f"快手搜索词数据获取失败,{response['msg']}\n")
+                return list
+            data = response['data']['data']
+
+        except Exception as exc:
+            Common.logger("sph-key-word").info(f"视频号搜索词{keyword}获取失败{exc}\n")
+            return list

+ 11 - 6
video_rewriting/video_processor.py

@@ -170,6 +170,8 @@ class VideoProcessor:
                     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:
+                            if name == "单点视频":
+                                sqlCollect.update_shp_dd_vid_4(v_id)
                             continue
                             continue
                     else:
                     else:
                         if video_share and video_share != 'None':
                         if video_share and video_share != 'None':
@@ -488,13 +490,16 @@ class VideoProcessor:
         pw_video_list = [new_video_path, pw_path]
         pw_video_list = [new_video_path, pw_path]
         Common.logger(mark).info(f"{task_mark}下的视频{url},视频与片尾开始拼接")
         Common.logger(mark).info(f"{task_mark}下的视频{url},视频与片尾开始拼接")
         video_path = FFmpeg.concatenate_videos(pw_video_list, video_path_url)  # 视频与片尾拼接到一起
         video_path = FFmpeg.concatenate_videos(pw_video_list, video_path_url)  # 视频与片尾拼接到一起
-        Common.logger(mark).info(f"{name}的{task_mark}下的视频{url},视频与片尾拼接成功")
-        time.sleep(1)
-        if video_share and video_share != 'None':
-            new_video_path = FFmpeg.single_video(video_path, video_path_url, zm)
+        if video_path:
+            Common.logger(mark).info(f"{name}的{task_mark}下的视频{url},视频与片尾拼接成功")
+            time.sleep(1)
+            if video_share and video_share != 'None':
+                new_video_path = FFmpeg.single_video(video_path, video_path_url, zm)
+            else:
+                new_video_path = video_path
+            return new_video_path
         else:
         else:
-            new_video_path = video_path
-        return new_video_path
+            return None