فهرست منبع

增加视频号单点功能

zhangyong 8 ماه پیش
والد
کامیت
c1c616315e
16فایلهای تغییر یافته به همراه243 افزوده شده و 269 حذف شده
  1. 63 0
      common/mysql_db_aigc.py
  2. 21 1
      common/sql_help.py
  3. 34 0
      data_channel/shipinhaodandian.py
  4. 68 0
      job_dd_sph.py
  5. 4 7
      job_dypl.py
  6. 5 31
      job_fj.py
  7. 3 6
      job_ksczz.py
  8. 3 31
      job_lq.py
  9. 5 32
      job_lsy.py
  10. 5 33
      job_lt.py
  11. 3 4
      job_sph.py
  12. 5 30
      job_wxk1.py
  13. 5 32
      job_wyt.py
  14. 4 32
      job_xx.py
  15. 4 30
      job_yht.py
  16. 11 0
      video_rewriting/video_processor.py

+ 63 - 0
common/mysql_db_aigc.py

@@ -0,0 +1,63 @@
+# -*- coding: utf-8 -*-
+"""
+数据库连接及操作
+"""
+import pymysql
+
+
+class AigcMysqlHelper:
+    @classmethod
+    def connect_mysql(cls):
+        connection = pymysql.connect(
+            host="rm-t4na9qj85v7790tf84o.mysql.singapore.rds.aliyuncs.com",
+            port=3306,  # 端口号
+            user="crawler_admin",  # mysql用户名
+            passwd="cyber#crawler_2023",  # mysql用户登录密码
+            db="aigc-admin-prod",  # 数据库名
+            # 如果数据库里面的文本是utf8编码的,charset指定是utf8
+            charset="utf8")
+        return connection
+
+    @classmethod
+    def get_values(cls, sql, params):
+        try:
+            # 连接数据库
+            connect = cls.connect_mysql()
+            # 返回一个 Cursor对象
+            mysql = connect.cursor()
+
+            # 执行 sql 语句
+            mysql.execute(sql, params)
+
+            # fetchall方法返回的是一个元组,里面每个元素也是元组,代表一行记录
+            data = mysql.fetchall()
+
+            # 关闭数据库连接
+            connect.close()
+
+            # 返回查询结果,元组
+            return data
+        except Exception as e:
+            print(f"get_values异常:{e}\n")
+
+    @classmethod
+    def update_values(cls, sql):
+        # 连接数据库
+        connect = cls.connect_mysql()
+        # 返回一个 Cursor对象
+        mysql = connect.cursor()
+        try:
+            # 执行 sql 语句
+            res = mysql.execute(sql)
+            # 注意 一定要commit,否则添加数据不生效
+            connect.commit()
+            return res
+        except Exception as e:
+            # 发生错误时回滚
+            connect.rollback()
+        # 关闭数据库连接
+        connect.close()
+
+
+
+

+ 21 - 1
common/sql_help.py

@@ -2,7 +2,7 @@ import os
 import sys
 from typing import Optional
 
-
+from common.mysql_db_aigc import AigcMysqlHelper
 
 sys.path.append(os.getcwd())
 from datetime import datetime
@@ -92,3 +92,23 @@ class sqlCollect():
         res = MysqlHelper.update_values(
             sql=insert_sql
         )
+
+    @classmethod
+    def get_shp_dd_data(cls, url):
+        """
+        获取视频号单点内容
+        """
+        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 from dandian_shipinhao where from_user_name = %s and has_used = 0 """
+        data = AigcMysqlHelper.get_values(sql, (url))
+        return data
+
+    @classmethod
+    def update_shp_dd_vid(cls, vid):
+        """
+        视频号单点修改状态为1
+        """
+        sql = f"""UPDATE dandian_shipinhao set has_used = 1 where video_id = '{vid}'"""
+        res = AigcMysqlHelper.update_values(
+            sql=sql
+        )
+        return res

+ 34 - 0
data_channel/shipinhaodandian.py

@@ -0,0 +1,34 @@
+from common.sql_help import sqlCollect
+
+
+class SPHDD:
+
+    @classmethod
+    def get_sphdd_data(cls, url):
+        data_list = sqlCollect.get_shp_dd_data(url)
+        list = []
+        if data_list:
+            for data in data_list:
+                video_id = data[0]
+                old_title = data[1]
+                # author_id = data[2]
+                author_name = data[3]
+                cover_url = data[4]
+                video_url = data[5]
+                # video_duration = data[6]
+                # from_user_id = data[7]
+                # from_user_name = data[8]
+                # from_group_id = data[9]
+                # from_group_name = data[10]
+                all_data = {"video_id": video_id, "cover": cover_url, "video_url": video_url, "rule": author_name,
+                            "old_title": old_title}
+                list.append(all_data)
+            return list
+        return list
+
+
+
+
+if __name__ == '__main__':
+
+    SPHDD.get_sphdd_data("杨昊")

+ 68 - 0
job_dd_sph.py

@@ -0,0 +1,68 @@
+import os
+import concurrent.futures
+
+import schedule
+import time
+import threading
+from common import Material
+# 控制读写速度的参数
+from video_rewriting.video_processor import VideoProcessor
+
+MAX_BPS = 120 * 1024 * 1024  # 120MB/s
+MAX_WORKERS = os.cpu_count() * 2  # 线程池最大工作线程数量
+READ_WRITE_CHUNK_SIZE = 1024 * 1024  # 每次读写的块大小 (1MB)
+SLEEP_INTERVAL = READ_WRITE_CHUNK_SIZE / MAX_BPS  # 控制每次读写的延迟时间
+# 全局锁,用于同步读写操作
+lock = threading.Lock()
+
+
+def video_task_start(data):
+    mark = VideoProcessor.main(data)
+    print(f"返回用户名{mark}")
+
+
+
+def controlled_io_operation(data):
+    with lock:
+        start_time = time.time()
+        time.sleep(SLEEP_INTERVAL)
+        end_time = time.time()
+        elapsed_time = end_time - start_time
+        if elapsed_time < SLEEP_INTERVAL:
+            time.sleep(SLEEP_INTERVAL - elapsed_time)
+    video_task_start(data)
+
+
+
+
+def video_start():
+    print("开始执行生成视频脚本.")
+
+    data = Material.feishu_list()
+    data = data[12]
+    with concurrent.futures.ThreadPoolExecutor(max_workers=MAX_WORKERS) as executor:
+        futures = {executor.submit(controlled_io_operation, data)}
+        for future in concurrent.futures.as_completed(futures):
+            try:
+                future.result()
+                print("处理结果: 成功")
+            except concurrent.futures.TimeoutError:
+                print("任务超时,已取消.")
+            except Exception as e:
+                print("处理任务时出现异常:", e)
+    print("执行生成视频脚本结束.")
+
+video_start()
+
+
+schedule.every(1).hours.do(video_start)
+# schedule.every(20).minutes.do(video_start)
+
+
+
+
+while True:
+    schedule.run_pending()
+    time.sleep(1)
+
+

+ 4 - 7
job_dypl.py

@@ -1,13 +1,10 @@
 import os
 import concurrent.futures
-import re
-
 import schedule
 import time
 import threading
-from common import Material, Common, Feishu
-# 控制读写速度的参数
-from video_rewriting.video_prep import getVideo
+from common import Material
+from video_rewriting.video_processor import VideoProcessor
 
 MAX_BPS = 120 * 1024 * 1024  # 120MB/s
 MAX_WORKERS = os.cpu_count() * 2  # 线程池最大工作线程数量
@@ -18,7 +15,7 @@ lock = threading.Lock()
 
 
 def video_task_start(data):
-    mark = getVideo.video_task(data)
+    mark = VideoProcessor.main(data)
     print(f"返回用户名{mark}")
 
 
@@ -59,7 +56,7 @@ def video_start():
 video_start()
 
 
-schedule.every(12).hours.do(video_start)
+schedule.every(6).hours.do(video_start)
 # schedule.every(20).minutes.do(video_start)
 
 

+ 5 - 31
job_fj.py

@@ -5,9 +5,8 @@ import re
 import schedule
 import time
 import threading
-from common import Material, Common, Feishu
-# 控制读写速度的参数
-from video_rewriting.video_prep import getVideo
+from common import Material
+from video_rewriting.video_processor import VideoProcessor
 
 MAX_BPS = 120 * 1024 * 1024  # 120MB/s
 MAX_WORKERS = os.cpu_count() * 2  # 线程池最大工作线程数量
@@ -15,23 +14,13 @@ READ_WRITE_CHUNK_SIZE = 1024 * 1024  # 每次读写的块大小 (1MB)
 SLEEP_INTERVAL = READ_WRITE_CHUNK_SIZE / MAX_BPS  # 控制每次读写的延迟时间
 # 全局锁,用于同步读写操作
 lock = threading.Lock()
-# 记录今天已经返回的用户名
-today = []
+
 
 
 def video_task_start(data):
-    # global today
-    # user_data_mark = data["mark"]
-    # # 开始准备执行生成视频脚本
-    # if user_data_mark is not None and user_data_mark in today:
-    #     Common.logger("log").info(f"视频脚本参数中的用户名 {user_data_mark} 今天已经返回过,不再启动线程。今天已经返回的用户名:{user_data_mark}")
-    #     print(f"视频脚本参数中的用户名 {user_data_mark} 今天已经返回过,不再启动线程。")
-    #     return
-    mark = getVideo.video_task(data)
+    mark = VideoProcessor.main(data)
     print(f"返回用户名{mark}")
-    # if mark:
-    #     today.append(mark)
-    #     Common.logger("log").info(f"返回用户名{mark}")
+
 
 # data = Material.feishu_list()
 # video_task_start(data[0])
@@ -66,23 +55,8 @@ def video_start():
             except Exception as e:
                 print("处理任务时出现异常:", e)
     print("执行生成视频脚本结束.")
-
-def usernames_today():
-    today.clear()
-    print("today 已清空")
-
-
 video_start()
-
-
-# 定时任务设置
-schedule.every().day.at("01:00").do(usernames_today)
-
-
 schedule.every(6).hours.do(video_start)
-
-
-
 while True:
     schedule.run_pending()
     time.sleep(1)

+ 3 - 6
job_ksczz.py

@@ -1,13 +1,10 @@
 import os
 import concurrent.futures
-import re
-
 import schedule
 import time
 import threading
-from common import Material, Common, Feishu
-# 控制读写速度的参数
-from video_rewriting.video_prep import getVideo
+from common import Material
+from video_rewriting.video_processor import VideoProcessor
 
 MAX_BPS = 120 * 1024 * 1024  # 120MB/s
 MAX_WORKERS = os.cpu_count() * 2  # 线程池最大工作线程数量
@@ -18,7 +15,7 @@ lock = threading.Lock()
 
 
 def video_task_start(data):
-    mark = getVideo.video_task(data)
+    mark = VideoProcessor.main(data)
     print(f"返回用户名{mark}")
 
 

+ 3 - 31
job_lq.py

@@ -1,13 +1,11 @@
 import os
 import concurrent.futures
-import re
 
 import schedule
 import time
 import threading
-from common import Material, Common, Feishu
-# 控制读写速度的参数
-from video_rewriting.video_prep import getVideo
+from common import Material
+from video_rewriting.video_processor import VideoProcessor
 
 MAX_BPS = 120 * 1024 * 1024  # 120MB/s
 MAX_WORKERS = os.cpu_count() * 2  # 线程池最大工作线程数量
@@ -15,23 +13,11 @@ READ_WRITE_CHUNK_SIZE = 1024 * 1024  # 每次读写的块大小 (1MB)
 SLEEP_INTERVAL = READ_WRITE_CHUNK_SIZE / MAX_BPS  # 控制每次读写的延迟时间
 # 全局锁,用于同步读写操作
 lock = threading.Lock()
-# 记录今天已经返回的用户名
-today = []
 
 
 def video_task_start(data):
-    # global today
-    # user_data_mark = data["mark"]
-    # # 开始准备执行生成视频脚本
-    # if user_data_mark is not None and user_data_mark in today:
-    #     Common.logger("log").info(f"视频脚本参数中的用户名 {user_data_mark} 今天已经返回过,不再启动线程。今天已经返回的用户名:{user_data_mark}")
-    #     print(f"视频脚本参数中的用户名 {user_data_mark} 今天已经返回过,不再启动线程。")
-    #     return
-    mark = getVideo.video_task(data)
+    mark = VideoProcessor.main(data)
     print(f"返回用户名{mark}")
-    # if mark:
-    #     today.append(mark)
-    #     Common.logger("log").info(f"返回用户名{mark}")
 
 # data = Material.feishu_list()
 # video_task_start(data[0])
@@ -67,22 +53,8 @@ def video_start():
                 print("处理任务时出现异常:", e)
     print("执行生成视频脚本结束.")
 
-def usernames_today():
-    today.clear()
-    print("today 已清空")
-
-
 video_start()
-
-
-# 定时任务设置
-schedule.every().day.at("01:00").do(usernames_today)
-
-
 schedule.every(6).hours.do(video_start)
-
-
-
 while True:
     schedule.run_pending()
     time.sleep(1)

+ 5 - 32
job_lsy.py

@@ -1,13 +1,11 @@
 import os
 import concurrent.futures
-import re
 
 import schedule
 import time
 import threading
-from common import Material, Common, Feishu
-# 控制读写速度的参数
-from video_rewriting.video_prep import getVideo
+from common import Material
+from video_rewriting.video_processor import VideoProcessor
 
 MAX_BPS = 120 * 1024 * 1024  # 120MB/s
 MAX_WORKERS = os.cpu_count() * 2  # 线程池最大工作线程数量
@@ -15,23 +13,13 @@ READ_WRITE_CHUNK_SIZE = 1024 * 1024  # 每次读写的块大小 (1MB)
 SLEEP_INTERVAL = READ_WRITE_CHUNK_SIZE / MAX_BPS  # 控制每次读写的延迟时间
 # 全局锁,用于同步读写操作
 lock = threading.Lock()
-# 记录今天已经返回的用户名
-today = []
+
 
 
 def video_task_start(data):
-    # global today
-    # user_data_mark = data["mark"]
-    # # 开始准备执行生成视频脚本
-    # if user_data_mark is not None and user_data_mark in today:
-    #     Common.logger("log").info(f"视频脚本参数中的用户名 {user_data_mark} 今天已经返回过,不再启动线程。今天已经返回的用户名:{user_data_mark}")
-    #     print(f"视频脚本参数中的用户名 {user_data_mark} 今天已经返回过,不再启动线程。")
-    #     return
-    mark = getVideo.video_task(data)
+    mark = VideoProcessor.main(data)
     print(f"返回用户名{mark}")
-    # if mark:
-    #     today.append(mark)
-    #     Common.logger("log").info(f"返回用户名{mark}")
+
 
 # data = Material.feishu_list()
 # video_task_start(data[0])
@@ -66,23 +54,8 @@ def video_start():
             except Exception as e:
                 print("处理任务时出现异常:", e)
     print("执行生成视频脚本结束.")
-
-def usernames_today():
-    today.clear()
-    print("today 已清空")
-
-
 video_start()
-
-
-# 定时任务设置
-schedule.every().day.at("01:00").do(usernames_today)
-
-
 schedule.every(6).hours.do(video_start)
-
-
-
 while True:
     schedule.run_pending()
     time.sleep(1)

+ 5 - 33
job_lt.py

@@ -1,13 +1,10 @@
 import os
 import concurrent.futures
-import re
-
 import schedule
 import time
 import threading
-from common import Material, Common, Feishu
-# 控制读写速度的参数
-from video_rewriting.video_prep import getVideo
+from common import Material
+from video_rewriting.video_processor import VideoProcessor
 
 MAX_BPS = 120 * 1024 * 1024  # 120MB/s
 MAX_WORKERS = os.cpu_count() * 2  # 线程池最大工作线程数量
@@ -15,23 +12,13 @@ READ_WRITE_CHUNK_SIZE = 1024 * 1024  # 每次读写的块大小 (1MB)
 SLEEP_INTERVAL = READ_WRITE_CHUNK_SIZE / MAX_BPS  # 控制每次读写的延迟时间
 # 全局锁,用于同步读写操作
 lock = threading.Lock()
-# 记录今天已经返回的用户名
-today = []
+
 
 
 def video_task_start(data):
-    # global today
-    # user_data_mark = data["mark"]
-    # # 开始准备执行生成视频脚本
-    # if user_data_mark is not None and user_data_mark in today:
-    #     Common.logger("log").info(f"视频脚本参数中的用户名 {user_data_mark} 今天已经返回过,不再启动线程。今天已经返回的用户名:{user_data_mark}")
-    #     print(f"视频脚本参数中的用户名 {user_data_mark} 今天已经返回过,不再启动线程。")
-    #     return
-    mark = getVideo.video_task(data)
+    mark = VideoProcessor.main(data)
     print(f"返回用户名{mark}")
-    # if mark:
-    #     today.append(mark)
-    #     Common.logger("log").info(f"返回用户名{mark}")
+
 
 # data = Material.feishu_list()
 # video_task_start(data[0])
@@ -66,23 +53,8 @@ def video_start():
             except Exception as e:
                 print("处理任务时出现异常:", e)
     print("执行生成视频脚本结束.")
-
-def usernames_today():
-    today.clear()
-    print("today 已清空")
-
-
 video_start()
-
-
-# 定时任务设置
-schedule.every().day.at("01:00").do(usernames_today)
-
-
 schedule.every(6).hours.do(video_start)
-
-
-
 while True:
     schedule.run_pending()
     time.sleep(1)

+ 3 - 4
job_sph.py

@@ -1,13 +1,12 @@
 import os
 import concurrent.futures
-import re
 
 import schedule
 import time
 import threading
-from common import Material, Common, Feishu
+from common import Material
 # 控制读写速度的参数
-from video_rewriting.video_prep import getVideo
+from video_rewriting.video_processor import VideoProcessor
 
 MAX_BPS = 120 * 1024 * 1024  # 120MB/s
 MAX_WORKERS = os.cpu_count() * 2  # 线程池最大工作线程数量
@@ -18,7 +17,7 @@ lock = threading.Lock()
 
 
 def video_task_start(data):
-    mark = getVideo.video_task(data)
+    mark = VideoProcessor.main(data)
     print(f"返回用户名{mark}")
 
 

+ 5 - 30
job_wxk1.py

@@ -1,13 +1,11 @@
 import os
 import concurrent.futures
-import re
 
 import schedule
 import time
 import threading
-from common import Material, Common, Feishu
-# 控制读写速度的参数
-from video_rewriting.video_prep import getVideo
+from common import Material
+from video_rewriting.video_processor import VideoProcessor
 
 MAX_BPS = 120 * 1024 * 1024  # 120MB/s
 MAX_WORKERS = os.cpu_count() * 2  # 线程池最大工作线程数量
@@ -15,23 +13,13 @@ READ_WRITE_CHUNK_SIZE = 1024 * 1024  # 每次读写的块大小 (1MB)
 SLEEP_INTERVAL = READ_WRITE_CHUNK_SIZE / MAX_BPS  # 控制每次读写的延迟时间
 # 全局锁,用于同步读写操作
 lock = threading.Lock()
-# 记录今天已经返回的用户名
-today = []
+
 
 
 def video_task_start(data):
-    # global today
-    # user_data_mark = data["mark"]
-    # # 开始准备执行生成视频脚本
-    # if user_data_mark is not None and user_data_mark in today:
-    #     Common.logger("log").info(f"视频脚本参数中的用户名 {user_data_mark} 今天已经返回过,不再启动线程。今天已经返回的用户名:{user_data_mark}")
-    #     print(f"视频脚本参数中的用户名 {user_data_mark} 今天已经返回过,不再启动线程。")
-    #     return
-    mark = getVideo.video_task(data)
+    mark = VideoProcessor.main(data)
     print(f"返回用户名{mark}")
-    # if mark:
-    #     today.append(mark)
-    #     Common.logger("log").info(f"返回用户名{mark}")
+
 
 # data = Material.feishu_list()
 # video_task_start(data[0])
@@ -67,22 +55,9 @@ def video_start():
                 print("处理任务时出现异常:", e)
     print("执行生成视频脚本结束.")
 
-def usernames_today():
-    today.clear()
-    print("today 已清空")
-
 
 video_start()
-
-
-# 定时任务设置
-schedule.every().day.at("01:00").do(usernames_today)
-
-
 schedule.every(6).hours.do(video_start)
-
-
-
 while True:
     schedule.run_pending()
     time.sleep(1)

+ 5 - 32
job_wyt.py

@@ -1,13 +1,11 @@
 import os
 import concurrent.futures
-import re
 
 import schedule
 import time
 import threading
-from common import Material, Common, Feishu
-# 控制读写速度的参数
-from video_rewriting.video_prep import getVideo
+from common import Material
+from video_rewriting.video_processor import VideoProcessor
 
 MAX_BPS = 120 * 1024 * 1024  # 120MB/s
 MAX_WORKERS = os.cpu_count() * 2  # 线程池最大工作线程数量
@@ -15,23 +13,13 @@ READ_WRITE_CHUNK_SIZE = 1024 * 1024  # 每次读写的块大小 (1MB)
 SLEEP_INTERVAL = READ_WRITE_CHUNK_SIZE / MAX_BPS  # 控制每次读写的延迟时间
 # 全局锁,用于同步读写操作
 lock = threading.Lock()
-# 记录今天已经返回的用户名
-today = []
+
 
 
 def video_task_start(data):
-    # global today
-    # user_data_mark = data["mark"]
-    # # 开始准备执行生成视频脚本
-    # if user_data_mark is not None and user_data_mark in today:
-    #     Common.logger("log").info(f"视频脚本参数中的用户名 {user_data_mark} 今天已经返回过,不再启动线程。今天已经返回的用户名:{user_data_mark}")
-    #     print(f"视频脚本参数中的用户名 {user_data_mark} 今天已经返回过,不再启动线程。")
-    #     return
-    mark = getVideo.video_task(data)
+    mark = VideoProcessor.main(data)
     print(f"返回用户名{mark}")
-    # if mark:
-    #     today.append(mark)
-    #     Common.logger("log").info(f"返回用户名{mark}")
+
 
 # data = Material.feishu_list()
 # video_task_start(data[0])
@@ -66,23 +54,8 @@ def video_start():
             except Exception as e:
                 print("处理任务时出现异常:", e)
     print("执行生成视频脚本结束.")
-
-def usernames_today():
-    today.clear()
-    print("today 已清空")
-
-
 video_start()
-
-
-# 定时任务设置
-schedule.every().day.at("01:00").do(usernames_today)
-
-
 schedule.every(6).hours.do(video_start)
-
-
-
 while True:
     schedule.run_pending()
     time.sleep(1)

+ 4 - 32
job_xx.py

@@ -1,13 +1,11 @@
 import os
 import concurrent.futures
-import re
 
 import schedule
 import time
 import threading
-from common import Material, Common, Feishu
-# 控制读写速度的参数
-from video_rewriting.video_prep import getVideo
+from common import Material
+from video_rewriting.video_processor import VideoProcessor
 
 MAX_BPS = 120 * 1024 * 1024  # 120MB/s
 MAX_WORKERS = os.cpu_count() * 2  # 线程池最大工作线程数量
@@ -15,23 +13,12 @@ READ_WRITE_CHUNK_SIZE = 1024 * 1024  # 每次读写的块大小 (1MB)
 SLEEP_INTERVAL = READ_WRITE_CHUNK_SIZE / MAX_BPS  # 控制每次读写的延迟时间
 # 全局锁,用于同步读写操作
 lock = threading.Lock()
-# 记录今天已经返回的用户名
-today = []
+
 
 
 def video_task_start(data):
-    # global today
-    # user_data_mark = data["mark"]
-    # # 开始准备执行生成视频脚本
-    # if user_data_mark is not None and user_data_mark in today:
-    #     Common.logger("log").info(f"视频脚本参数中的用户名 {user_data_mark} 今天已经返回过,不再启动线程。今天已经返回的用户名:{user_data_mark}")
-    #     print(f"视频脚本参数中的用户名 {user_data_mark} 今天已经返回过,不再启动线程。")
-    #     return
-    mark = getVideo.video_task(data)
+    mark = VideoProcessor.main(data)
     print(f"返回用户名{mark}")
-    # if mark:
-    #     today.append(mark)
-    #     Common.logger("log").info(f"返回用户名{mark}")
 
 # data = Material.feishu_list()
 # video_task_start(data[0])
@@ -66,23 +53,8 @@ def video_start():
             except Exception as e:
                 print("处理任务时出现异常:", e)
     print("执行生成视频脚本结束.")
-
-def usernames_today():
-    today.clear()
-    print("today 已清空")
-
-
 video_start()
-
-
-# 定时任务设置
-schedule.every().day.at("01:00").do(usernames_today)
-
-
 schedule.every(6).hours.do(video_start)
-
-
-
 while True:
     schedule.run_pending()
     time.sleep(1)

+ 4 - 30
job_yht.py

@@ -1,13 +1,12 @@
 import os
 import concurrent.futures
-import re
 
 import schedule
 import time
 import threading
-from common import Material, Common, Feishu
+from common import Material
 # 控制读写速度的参数
-from video_rewriting.video_prep import getVideo
+from video_rewriting.video_processor import VideoProcessor
 
 MAX_BPS = 120 * 1024 * 1024  # 120MB/s
 MAX_WORKERS = os.cpu_count() * 2  # 线程池最大工作线程数量
@@ -15,23 +14,12 @@ READ_WRITE_CHUNK_SIZE = 1024 * 1024  # 每次读写的块大小 (1MB)
 SLEEP_INTERVAL = READ_WRITE_CHUNK_SIZE / MAX_BPS  # 控制每次读写的延迟时间
 # 全局锁,用于同步读写操作
 lock = threading.Lock()
-# 记录今天已经返回的用户名
-today = []
+
 
 
 def video_task_start(data):
-    global today
-    # user_data_mark = data["mark"]
-    # # 开始准备执行生成视频脚本
-    # if user_data_mark is not None and user_data_mark in today:
-    #     Common.logger("log").info(f"视频脚本参数中的用户名 {user_data_mark} 今天已经返回过,不再启动线程。今天已经返回的用户名:{user_data_mark}")
-    #     print(f"视频脚本参数中的用户名 {user_data_mark} 今天已经返回过,不再启动线程。")
-    #     return
-    mark = getVideo.video_task(data)
+    mark = VideoProcessor.main(data)
     print(f"返回用户名{mark}")
-    # if mark:
-    #     today.append(mark)
-    #     Common.logger("log").info(f"返回用户名{mark}")
 
 # data = Material.feishu_list()
 # video_task_start(data[0])
@@ -67,22 +55,8 @@ def video_start():
                 print("处理任务时出现异常:", e)
     print("执行生成视频脚本结束.")
 
-def usernames_today():
-    today.clear()
-    print("today 已清空")
-
-
 video_start()
-
-
-# 定时任务设置
-schedule.every().day.at("01:00").do(usernames_today)
-
-
 schedule.every(6).hours.do(video_start)
-
-
-
 while True:
     schedule.run_pending()
     time.sleep(1)

+ 11 - 0
video_rewriting/video_processor.py

@@ -20,6 +20,8 @@ from common.sql_help import sqlCollect
 from data_channel.shipinhao import SPH
 
 # 读取配置文件
+from data_channel.shipinhaodandian import SPHDD
+
 config = configparser.ConfigParser()
 config.read('./config.ini')
 
@@ -129,6 +131,11 @@ class VideoProcessor:
                         # 上传视频和封面,并更新数据库
                         values = cls.upload_video_and_thumbnail(new_video_path, cover, v_id, new_title, task_mark, name, piaoquan_id,
                                                        video_path_url, mark, channel_id, url, old_title, title, rule)
+                        # 更新已使用的视频号状态
+                        if name == "视频号单点":
+                            sphdd_status = sqlCollect.update_shp_dd_vid(v_id)
+                            if sphdd_status == 1:
+                                Common.logger("log").info(f"{name}的{task_mark}下的ID{url} 视频修改已使用,状态已修改")
                         if values:
                             if name == "王雪珂":
                                 sheet = "vfhHwj"
@@ -154,6 +161,8 @@ class VideoProcessor:
                                 sheet = "Bsg5UR"
                             elif name == "视频号品类账号":
                                 sheet = "b0uLWw"
+                            elif name == "视频号单点":
+                                sheet = "ptgCXW"
                             Feishu.insert_columns("ILb4sa0LahddRktnRipcu2vQnLb", sheet, "ROWS", 1, 2)
                             time.sleep(0.5)
                             Feishu.update_values("ILb4sa0LahddRktnRipcu2vQnLb", sheet, "A2:Z2", values)
@@ -179,6 +188,8 @@ class VideoProcessor:
             return KS.get_ks_url(task_mark, url, number, mark, feishu_id, cookie_sheet, channel_id)
         elif channel_id == "快手创作者版":
             return KsFeedVideo.get_data()
+        elif channel_id == "视频号单点":
+            return SPHDD.get_sphdd_data(url)
 
     @classmethod
     def generate_title(cls, video, title):