zhangyong 5 月之前
父节点
当前提交
8a6f09a599
共有 3 个文件被更改,包括 59 次插入0 次删除
  1. 34 0
      data_channel/sph_feed.py
  2. 20 0
      job_sph_feed.py
  3. 5 0
      video_rewriting/video_processor.py

+ 34 - 0
data_channel/sph_feed.py

@@ -0,0 +1,34 @@
+from common import AliyunLogger
+from common.sql_help import sqlCollect
+
+
+class SPHFeed:
+    @classmethod
+    def get_feed_date(cls):
+        try:
+            data_list = sqlCollect.get_feed_data("视频号")
+            list = []
+            if data_list:
+                for data in data_list:
+                    cover_url = data[3]
+                    video_url = data[2]
+                    if video_url and cover_url:
+                        video_id = data[0]
+                        channel = data[1]
+                        title = data[4]
+                        log_data = f"user:{channel},,video_id:{video_id},,video_url:{video_url},,original_title:{title}"
+                        AliyunLogger.logging(channel, channel, video_url, video_id, "扫描到一条视频",
+                                             "2001", log_data)
+                        AliyunLogger.logging(channel, channel, video_url, video_id, "符合规则等待改造",
+                                             "2004", log_data)
+                        all_data = {"video_id": video_id, "cover": cover_url, "video_url": video_url, "old_title": title, "rule":''}
+                        list.append(all_data)
+                return list
+            else:
+                return list
+        except Exception:
+            return list
+
+
+if __name__ == '__main__':
+    SPHFeed.get_feed_date()

+ 20 - 0
job_sph_feed.py

@@ -0,0 +1,20 @@
+
+import time
+from common import Material
+
+from video_rewriting.video_processor import VideoProcessor
+def video_task_start():
+    """处理视频任务,返回用户名并根据结果决定延迟时间"""
+    data = Material.feishu_list()[17]
+    while True:
+        try:
+            print("开始执行任务")
+            mark = VideoProcessor.main(data)
+            print(f"返回用户名: {mark}")
+            time.sleep(120 if mark else 120)  # 根据 mark 是否为空设置延迟
+        except Exception as e:
+            print("处理任务时出现异常:", e)
+            time.sleep(10)
+            continue
+if __name__ == '__main__':
+    video_task_start()

+ 5 - 0
video_rewriting/video_processor.py

@@ -29,6 +29,7 @@ from data_channel.shipinhao import SPH
 
 # 读取配置文件
 from data_channel.shipinhaodandian import SPHDD
+from data_channel.sph_feed import SPHFeed
 from data_channel.sph_keyword import SphKeyword
 from data_channel.sph_ls import SPHLS
 
@@ -415,6 +416,8 @@ class VideoProcessor:
                                 sheet = "Tgpikc"
                             elif name == "快手推荐流":
                                 sheet = "9Ii8lw"
+                            elif name == "视频号推荐流":
+                                sheet = "hMBv7T"
                             Feishu.insert_columns("ILb4sa0LahddRktnRipcu2vQnLb", sheet, "ROWS", 1, 2)
                             time.sleep(0.5)
                             Feishu.update_values("ILb4sa0LahddRktnRipcu2vQnLb", sheet, "A2:Z2", values)
@@ -457,6 +460,8 @@ class VideoProcessor:
             return SphKeyword.get_key_word(url, task_mark, mark, channel_id, name)
         elif channel_id == '快手推荐流':
             return KSFeed.get_feed_date()
+        elif channel_id == '视频号推荐流':
+            return SPHFeed.get_feed_date()
 
 
     @classmethod