Browse Source

增加redis去重

zhangyong 8 months ago
parent
commit
ac80dc0925

+ 1 - 1
common/common_log.py

@@ -31,7 +31,7 @@ class Common:
         使用 logger 模块生成日志
         """
         # 日志路径
-        log_dir = f"./{log_type}/logs/"
+        log_dir = f"./logs/{log_type}/"
         log_path = os.getcwd() + os.sep + log_dir
         if not os.path.isdir(log_path):
             os.makedirs(log_path)

+ 33 - 29
common/feishu_form.py

@@ -1,4 +1,5 @@
 # -*- coding: utf-8 -*-
+import json
 import os
 import random
 import sys
@@ -56,57 +57,60 @@ class Material():
                     if item and item not in {'None', ''}:
                         return len(item.split(separator))
                     return 0
-
                 video_id_total = count_items(str(channel_url), ',')
                 title_total = count_items(str(title), '/')
                 video_ending_total = count_items(str(video_ending), ',')
-
                 values = [channel_id, video_id_total, piaoquan_id, video_share, video_ending_total, crop_tool, gg_duration, title_total]
                 filtered_values = [str(value) for value in values if value is not None and value != "None"]
                 task_mark = "_".join(map(str, filtered_values))
                 if piaoquan_id and piaoquan_id not in {'None', ''}:
-                    number_dict = {
-                        "task_mark": task_mark,
-                        "channel_id": channel_id,
-                        "channel_url": channel_url,
-                        "piaoquan_id": piaoquan_id,
-                        "number": number,
-                        "title": title,
-                        "video_share": video_share,
-                        "video_ending": video_ending,
-                        "crop_total": crop_tool,
-                        "gg_duration_total": gg_duration,
-                    }
-                    processed_list.append(number_dict)
-                    if ls_number and ls_number not in {'None', ''}:
-                        if channel_id == "抖音":
-                            new_channel_id = "抖音历史"
-                        if channel_id == "快手":
-                            new_channel_id = "快手历史"
-                        values = [new_channel_id, video_id_total, piaoquan_id, video_share, video_ending_total, crop_tool,
-                                  gg_duration, title_total]
-                        filtered_values = [str(value) for value in values if value is not None and value != "None"]
-                        task_mark = "_".join(map(str, filtered_values))
+                    if ',' in channel_url:
+                        channel_url = channel_url.split(',')
+                    else:
+                        channel_url = channel_url
+                    for user in channel_url:
                         number_dict = {
                             "task_mark": task_mark,
-                            "channel_id": new_channel_id,
-                            "channel_url": channel_url,
+                            "channel_id": channel_id,
+                            "channel_url": user,
                             "piaoquan_id": piaoquan_id,
-                            "number": ls_number,
+                            "number": number,
                             "title": title,
                             "video_share": video_share,
                             "video_ending": video_ending,
                             "crop_total": crop_tool,
                             "gg_duration_total": gg_duration,
                         }
-                        processed_list.append(number_dict)
+                        processed_list.append(json.dumps(number_dict, ensure_ascii=False))
+                        if ls_number and ls_number not in {'None', ''}:
+                            if channel_id == "抖音":
+                                new_channel_id = "抖音历史"
+                            if channel_id == "快手":
+                                new_channel_id = "快手历史"
+                            values = [new_channel_id, video_id_total, piaoquan_id, video_share, video_ending_total, crop_tool,
+                                      gg_duration, title_total]
+                            filtered_values = [str(value) for value in values if value is not None and value != "None"]
+                            task_mark = "_".join(map(str, filtered_values))
+                            number_dict = {
+                                "task_mark": task_mark,
+                                "channel_id": new_channel_id,
+                                "channel_url": user,
+                                "piaoquan_id": piaoquan_id,
+                                "number": ls_number,
+                                "title": title,
+                                "video_share": video_share,
+                                "video_ending": video_ending,
+                                "crop_total": crop_tool,
+                                "gg_duration_total": gg_duration,
+                            }
+                            processed_list.append(number_dict)
 
                 else:
                     return processed_list
 
             return processed_list
         except:
-            processed_list
+            return processed_list
 
     """
     获取对应片尾+srt

+ 14 - 13
common/redis.py

@@ -35,19 +35,20 @@ class SyncRedisHelper:
 
 
 def get_data(name, data):
-    key = f"task:{name}"
+    task = f"task:{name}"
+    lock = f"lock:{name}"
     helper = SyncRedisHelper()
     client = helper.get_client()
-    if not client.exists('wangxueke-task'):
-        acquire_lock = client.set('wangxueke-lock', 1, ex=600, nx=True)
+    if not client.exists(task):
+        acquire_lock = client.set(lock, 1, ex=120, nx=True)
         if not acquire_lock:
-            return
-        data = [{}, {}, {}]
-        client.rpush('wangxueke-task', *data)
-    return client.lpop('wangxueke-task')
-
-value = get_data('xiaoniangao', '1234857')
-if value is None:
-    print("Value does not exist")
-else:
-    print(f"Retrieved value: {value}")
+            return None
+
+        client.rpush(task, *data)
+    return client.lpop(task)
+
+# value = get_data('xiaoniangao', '1234857')
+# if value is None:
+#     print("Value does not exist")
+# else:
+#     print(f"Retrieved value: {value}")

+ 1 - 1
data_channel/douyin.py

@@ -98,6 +98,6 @@ class DY:
                         all_data = {"video_id": video_id, "cover": cover_url, "video_url": video_url, "rule": video_percent, "old_title": old_title}
                         list.append(all_data)
                         if len(list) == int(number):
-                            Common.logger("log").info(f"获取抖音视频总数:{len(list)}\n")
+                            Common.logger(mark).info(f"获取抖音视频总数:{len(list)}\n")
                             return list
         return list

+ 2 - 2
data_channel/kuaishou.py

@@ -117,10 +117,10 @@ class KS:
                             all_data = {"video_id": video_id, "cover": cover_url, "video_url": video_url, "rule": video_percent, "old_title": old_title}
                             list.append(all_data)
                             if len(list) == int(number):
-                                Common.logger("log").info(f"获取快手视频总数:{len(list)}\n")
+                                Common.logger(mark).info(f"获取快手视频总数:{len(list)}\n")
                                 return list
             except Exception as exc:
-                Common.logger("warning").warning(f"{name}的快手获取数据失败:{exc}\n")
+                Common.logger("ks").warning(f"{name}的快手获取数据失败:{exc}\n")
                 return list
         return list
 

+ 1 - 1
data_channel/kuaishouchuangzuozhe.py

@@ -288,7 +288,7 @@ class KsFeedVideo:
                     time.sleep(0.5)
                     Feishu.update_values("PlcisKhObhzmBothRutc65sJnph", "8fQxFv", "A3:Z3", values)
                     if len(list) == int(number):
-                        Common.logger("log").info(f"获取快手创作者视频总数:{len(list)}\n")
+                        Common.logger("ks-czz").info(f"获取快手创作者视频总数:{len(list)}\n")
                         return list
                 time.sleep(5)
             except Exception as exc:

+ 3 - 3
data_channel/piaoquan.py

@@ -125,12 +125,12 @@ class PQ:
                     all_data = {"video_id": video_id, "cover": cover, "video_url": video_url, "rule": "无", "old_title": old_title}
                     list.append(all_data)
                     if len(list) == int(number):
-                        Common.logger("log").info(f"获取视频总数:{len(list)}\n")
+                        Common.logger("pq").info(f"获取视频总数:{len(list)}\n")
                         return list
-            Common.logger("log").info(f"获取票圈视频总数:{len(list)}\n")
+            Common.logger("pq").info(f"获取票圈视频总数:{len(list)}\n")
             return list
         except Exception as e:
-            Common.logger("log").warning(f"获取音频视频链接失败:{e}\n")
+            Common.logger("pq").warning(f"获取音频视频链接失败:{e}\n")
             return ""
 
     """

+ 1 - 1
data_channel/shipinhao.py

@@ -127,7 +127,7 @@ class SPH:
                                 all_data = {"video_id": objectId, "cover": cover, "video_url": video_url, "rule": video_percent, "old_title": old_title}
                                 list.append(all_data)
                                 if len(list) == int(number):
-                                    Common.logger("log").info(f"获取视频号视频总数:{len(list)}\n")
+                                    Common.logger(mark).info(f"获取视频号视频总数:{len(list)}\n")
                                     return list
                             else:
                                 Common.logger("sph").info(

+ 46 - 46
job_pl_dy.py

@@ -19,51 +19,51 @@ def video_task_start(data):
     print(f"返回用户名{mark}")
 
 
-data = Material.feishu_list()
-video_task_start(data[10])
-
-
-# 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[10]
-#     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(6).hours.do(video_start)
-# # schedule.every(20).minutes.do(video_start)
-#
-#
-#
-#
-# while True:
-#     schedule.run_pending()
-#     time.sleep(1)
+# data = Material.feishu_list()
+# video_task_start(data[10])
+
+
+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[10]
+    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(6).hours.do(video_start)
+# schedule.every(20).minutes.do(video_start)
+
+
+
+
+while True:
+    schedule.run_pending()
+    time.sleep(1)
 
 

+ 40 - 40
job_pl_dy_1.py

@@ -21,45 +21,45 @@ def video_task_start(data):
     print(f"返回用户名{mark}")
 
 
-data = Material.feishu_list()
-video_task_start(data[5])
-
-
-# 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[5]
-#     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(6).hours.do(video_start)
-# while True:
-#     schedule.run_pending()
-#     time.sleep(1)
+# data = Material.feishu_list()
+# video_task_start(data[5])
+
+
+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[5]
+    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(6).hours.do(video_start)
+while True:
+    schedule.run_pending()
+    time.sleep(1)
 
 

+ 19 - 34
job_wxk.py

@@ -1,64 +1,49 @@
 import os
 import concurrent.futures
-
-import schedule
 import time
 import threading
 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  # 线程池最大工作线程数量
 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}")
-
-
-# data = Material.feishu_list()
-# video_task_start(data[0])
+    """处理视频任务,返回用户名并根据结果决定延迟时间"""
+    try:
+        mark = VideoProcessor.main(data)
+        print(f"返回用户名: {mark}")
+        time.sleep(10 if mark else 120)  # 根据 mark 是否为空设置延迟
+        return mark
+    except Exception as e:
+        print("处理任务时出现异常:", e)
+        return None
 
 def controlled_io_operation(data):
+    """同步控制IO操作并执行视频任务"""
     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)
+    return video_task_start(data)
 
 def video_start():
+    """启动视频生成任务"""
     print("开始执行生成视频脚本.")
-    data = Material.feishu_list()
-    data = data[0]
+    data = Material.feishu_list()[0]
     with concurrent.futures.ThreadPoolExecutor(max_workers=MAX_WORKERS) as executor:
-        futures = {executor.submit(controlled_io_operation, data)}
+        futures = [executor.submit(controlled_io_operation, data) for _ in range(MAX_WORKERS)]
         for future in concurrent.futures.as_completed(futures):
             try:
-                future.result()
-                print("处理结果: 成功")
-            except concurrent.futures.TimeoutError:
-                print("任务超时,已取消.")
+                result = future.result()
+                print(f"处理结果: 成功, 用户名: {result}")
             except Exception as e:
                 print("处理任务时出现异常:", e)
     print("执行生成视频脚本结束.")
 
-
-
-video_start()
-schedule.every(6).hours.do(video_start)
-
-
-
 while True:
-    schedule.run_pending()
-    time.sleep(1)
-
-
+    video_start()

+ 0 - 348
video_rewriting/video_prep.py

@@ -1,348 +0,0 @@
-import configparser
-import os
-import random
-import re
-import sys
-import threading
-import time
-
-from datetime import datetime
-import concurrent.futures
-
-from common.tts_help import TTS
-
-sys.path.append(os.getcwd())
-
-from common import Material, Feishu, Common, Oss
-from common.ffmpeg import FFmpeg
-from common.gpt4o_help import GPT4o
-from data_channel.douyin import DY
-from data_channel.kuaishou import KS
-from data_channel.kuaishouchuangzuozhe import KsFeedVideo
-from data_channel.piaoquan import PQ
-from common.sql_help import sqlCollect
-from data_channel.shipinhao import SPH
-
-config = configparser.ConfigParser()
-config.read('./config.ini')
-
-
-class getVideo:
-
-    """
-    根据标示+任务标示创建目录
-    """
-    @classmethod
-    def create_folders(cls, mark, task_mark):
-        video_path_url = config['PATHS']['VIDEO_PATH'] + mark + "/" + task_mark + "/"
-        if not os.path.exists(video_path_url):
-            os.makedirs(video_path_url)
-        return video_path_url
-
-    """
-    随机生成ID
-    """
-    @classmethod
-    def random_id(cls):
-        now = datetime.now()
-        rand_num = random.randint(10000, 99999)
-        oss_id = "{}{}".format(now.strftime("%Y%m%d%H%M%S"), rand_num)
-        return oss_id
-
-
-    """
-    删除文件
-    """
-    @classmethod
-    def remove_files(cls, video_path_url):
-        if os.path.exists(video_path_url) and os.path.isdir(video_path_url):
-            for root, dirs, files in os.walk(video_path_url):
-                for file in files:
-                    file_path = os.path.join(root, file)
-                    os.remove(file_path)
-                for dir in dirs:
-                    dir_path = os.path.join(root, dir)
-                    os.rmdir(dir_path)
-
-    """
-    飞书数据处理
-    """
-    @classmethod
-    def video_task(cls, data):
-        mark = data["mark"]
-        name = data["name"]
-        feishu_id = data["feishu_id"]
-        feishu_sheet = data["feishu_sheet"]
-        cookie_sheet = data["cookie_sheet"]
-        pz_sheet = '500Oe0'
-        pw_sheet = 'DgX7vC'
-        task_data = Material.get_task_data(feishu_id, feishu_sheet)
-        # task_data = task_data[::-1]
-        if len(task_data) == 0:
-            Feishu.bot(mark, '机器自动改造消息通知', f'今日任务为空,请关注', name)
-            return mark
-        lock = threading.Lock()
-        def process_task(task):
-            task_mark = task["task_mark"]  # 任务标示
-            channel_id = str(task["channel_id"])
-            channel_urls = str(task["channel_url"])
-            piaoquan_id = str(task["piaoquan_id"])
-            number = task["number"]  # 指定条数
-            title = task["title"]
-            video_share = task["video_share"]
-            video_ending = task["video_ending"]
-            crop_total = task["crop_total"]
-            gg_duration_total = task["gg_duration_total"]
-            video_path_url = cls.create_folders(mark, str(task_mark))  # 创建目录
-            zm = Material.get_pzsrt_data("summary", pz_sheet, video_share)  # 获取srt
-            if zm == '':
-                Feishu.bot(mark, '机器自动改造消息通知', f'{task_mark}任务下片中标示填写错误,请关注!!!!', name)
-            if ',' in channel_urls:
-                channel_url = channel_urls.split(',')
-            else:
-                channel_url = [channel_urls]
-            for url in channel_url:
-                Common.logger("log").info(f"{name}的{task_mark}下的用户:{channel_url}开始获取视频")
-                if channel_id == "抖音":
-                    data_list = DY.get_dy_url(task_mark, url, number, mark, feishu_id, cookie_sheet, channel_id, name)
-                elif channel_id == "票圈":
-                    data_list = PQ.get_pq_url(task_mark, url, number, mark)
-                elif channel_id == "视频号":
-                    data_list = SPH.get_sph_url(task_mark, url, number, mark)
-                elif channel_id == "快手":
-                    data_list = KS.get_ks_url(task_mark, url, number, mark, feishu_id, cookie_sheet, channel_id, name)
-                elif channel_id == "快手创作者版":
-                    data_list = KsFeedVideo.get_data()
-                    if len(data_list) == 0:
-                        Common.logger("log").info(f"{name}的{task_mark}下的视频ID{url} 已经改造过了")
-                        Feishu.bot("快手创作者版", '机器自动改造消息通知', f'本轮没有获取到改造的视频链接', "王雪珂")
-                        cls.remove_files(video_path_url)
-                        continue
-                if len(data_list) == 0:
-                    Common.logger("log").info(f"{name}的{task_mark}下的视频ID{url} 已经改造过了")
-                    Feishu.bot(mark, '机器自动改造消息通知', f'{task_mark}任务下的用户ID{url},没有已经改造的视频了', name)
-                    cls.remove_files(video_path_url)
-                    continue
-                Common.logger("log").info(f"{name}的{task_mark}下的ID{url} 获取视频完成,共{len(data_list)}条")
-
-                try:
-                    for video in data_list:
-                        new_title = video['old_title'].strip().replace("\n", "") \
-                            .replace("/", "").replace("\\", "").replace("\r", "") \
-                            .replace(":", "").replace("*", "").replace("?", "") \
-                            .replace("?", "").replace('"', "").replace("<", "") \
-                            .replace(">", "").replace("|", "").replace(" ", "") \
-                            .replace("&NBSP", "").replace(".", "。").replace(" ", "") \
-                            .replace("'", "").replace("#", "").replace("Merge", "")
-                        if title == "原标题":
-                            if new_title == "" or len(new_title) == 0 or new_title == None:
-                                new_title = '⭕分享给大家一个视频!值得细品!'
-                        elif title == "AI标题":
-                            if new_title == "" or len(new_title) == 0 or new_title == None:
-                                new_title = '⭕分享给大家一个视频!值得细品!'
-                            else:
-                                new_title = GPT4o.get_ai_title(new_title)
-                        else:
-                            if '/' in title:
-                                titles = title.split('/')
-                            else:
-                                titles = [title]
-                            new_title = random.choice(titles)
-                        v_id = video["video_id"]
-                        cover = video["cover"]
-                        video_url = video["video_url"]
-                        rule = video['rule']
-                        old_title = video['old_title']
-                        if old_title == "" or len(old_title) == 0 or old_title == None:
-                            old_title = '⭕分享给大家一个视频!值得细品!'
-                            Common.logger("title").info(f"{name}的{task_mark}下的视频{url},标题为空,使用兜底标题生成片尾")
-
-                        time.sleep(1)
-                        pw_random_id = cls.random_id()
-                        if channel_id == "票圈" or channel_id == "快手创作者版":
-                            new_video_path = PQ.download_video(video_url, video_path_url, v_id)  # 下载视频地址
-                        else:
-                            new_video_path = Oss.download_video_oss(video_url, video_path_url, v_id)  # 下载视频地址
-                            Common.logger("log").info(f"{name}的{task_mark}下的视频{url},{new_video_path}视频下载成功")
-                        if not os.path.isfile(new_video_path):
-                            Common.logger("log").info(f"{name}的{task_mark}下的视频{url},{new_video_path}视频下载失败")
-                            cls.remove_files(video_path_url)
-                            continue
-                        Common.logger("log").info(f"{name}的{task_mark}下的视频{url},{new_video_path}视频下载成功")
-                        if crop_total and crop_total != 'None':  # 判断是否需要裁剪
-                            new_video_path = FFmpeg.video_crop(new_video_path, video_path_url, pw_random_id)
-                        if gg_duration_total and gg_duration_total != 'None':  # 判断是否需要指定视频时长
-                            new_video_path = FFmpeg.video_ggduration(new_video_path, video_path_url, pw_random_id, gg_duration_total)
-                        width, height = FFmpeg.get_w_h_size(new_video_path)
-                        if width < height:
-                            new_video_path = FFmpeg.update_video_h_w(new_video_path, video_path_url, pw_random_id)
-                            time.sleep(1)
-                            if os.path.isfile(new_video_path):
-                                if new_title != "" or len(new_title) != 0 or new_title != None:
-                                    new_title_re = re.sub(r'[^\w\s\u4e00-\u9fff,。!?]', '', new_title)
-                                    if len(new_title_re) > 12:
-                                        new_text = '\n'.join(
-                                            [new_title_re[i:i + 12] for i in range(0, len(new_title_re), 12)])
-                                    new_video_path = FFmpeg.add_video_zm(new_video_path, video_path_url, pw_random_id, new_text)
-                        if video_ending and video_ending != 'None':
-                            if video_ending == "AI片尾引导":
-                                pw_srt_text = GPT4o.get_ai_pw(old_title)
-                                if pw_srt_text:
-                                    pw_url = TTS.get_pw_zm(pw_srt_text)
-                                    Common.logger("log").info(f"{name}的{task_mark}下的视频{url},获取AI片尾音频成功")
-                                    if pw_url:
-                                        pw_mp3_path = TTS.download_mp3(pw_url, video_path_url, pw_random_id)
-                                        pw_url_sec = FFmpeg.get_video_duration(pw_mp3_path)  # 获取片尾秒数
-                                        Common.logger("log").info(f"{name}的{task_mark}下的视频{url},获取AI片尾秒数成功{pw_url_sec}")
-                                        pw_srt = TTS.getSrt(pw_url)
-                                        Common.logger("log").info(f"{name}的{task_mark}下的视频{url},获取AI片尾srt成功")
-                                    else:
-                                        Feishu.bot(mark, 'TTS获取失败提示', f'无法获取到片尾音频,及时更换token', "张勇")
-                                        Common.logger("log").info(f"{name}的{task_mark}下的视频{url},获取AI片尾失败")
-                                        continue
-                                else:
-                                    Common.logger("log").info(f"{name}的{task_mark}下的视频{url},获取AI片尾失败")
-                                    continue
-                            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", pw_sheet, ending)  # 获取srt
-                                if pw_list:
-                                    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, video_path_url, pw_random_id)
-                                else:
-                                    Feishu.bot(mark, '机器自动改造消息通知', f'{task_mark}任务下片尾标示错误,请关注!!!!', name)
-                            for attempt in range(3):
-                                jpg_path = FFmpeg.video_png(new_video_path, video_path_url, pw_random_id)  # 生成视频最后一帧jpg
-                                if os.path.isfile(jpg_path):
-                                    Common.logger("log").info(f"{name}的{task_mark}下的视频{url},生成视频最后一帧成功")
-                                    break
-                                time.sleep(1)
-                            if not os.path.isfile(jpg_path):
-                                Feishu.bot(mark, '机器自动改造消息通知', f'{task_mark}任务用户{url}下的视频{v_id},获取视频最后一帧失败,请关注', name)
-                                cls.remove_files(video_path_url)
-                                continue
-                            for attempt in range(3):
-                                Common.logger("log").info(f"{name}的{task_mark}下的视频{url},获取mp3成功")
-                                pw_path = FFmpeg.pw_video(jpg_path, video_path_url, pw_mp3_path, pw_srt, pw_random_id, pw_mp3_path)  # 生成片尾视频
-                                if os.path.isfile(pw_path):
-                                    Common.logger("log").info(f"{task_mark}下的视频{url},生成片尾视频成功")
-                                    break
-                                time.sleep(1)
-                            if not os.path.isfile(pw_path):
-                                Feishu.bot(mark, '机器自动改造消息通知', f'{task_mark}任务用户{url}下的视频{v_id},生成片尾视频失败,请关注',
-                                           name)
-                                cls.remove_files(video_path_url)
-                                continue
-                            pw_video_list = [new_video_path, pw_path]
-                            Common.logger("log").info(f"{task_mark}下的视频{url},视频与片尾开始拼接")
-                            video_path = FFmpeg.concatenate_videos(pw_video_list, video_path_url)  # 视频与片尾拼接到一起
-                            Common.logger("log").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
-                        else:
-                            if video_share and video_share != 'None':
-                                new_video_path = FFmpeg.single_video(new_video_path, video_path_url, zm)
-                        time.sleep(1)
-                        oss_id = cls.random_id()
-                        Common.logger("log").info(f"{name}的{task_mark}下的视频{url},开始发送oss")
-                        oss_object_key = Oss.stitching_sync_upload_oss(new_video_path, oss_id)  # 视频发送OSS
-                        Common.logger("log").info(f"{name}的{task_mark}下的视频{url},发送oss成功{oss_object_key}")
-                        status = oss_object_key.get("status")
-                        if status == 200:
-                            oss_object_key = oss_object_key.get("oss_object_key")
-                            time.sleep(1)
-                            jpg_path = PQ.download_video_jpg(cover, video_path_url, v_id)  # 下载视频封面
-                            if os.path.isfile(jpg_path):
-                                oss_jpg_key = Oss.stitching_fm_upload_oss(jpg_path, oss_id)  # 封面发送OSS
-                                status = oss_jpg_key.get("status")
-                                if status == 200:
-                                    jpg = oss_jpg_key.get("oss_object_key")
-                                else:
-                                    jpg = None
-                            else:
-                                jpg = None
-                            code = PQ.insert_piaoquantv(oss_object_key, new_title, jpg, piaoquan_id)
-                            if code:
-                                Common.logger("log").info(f"{name}的{task_mark}下的视频ID{v_id}发送成功")
-                                sqlCollect.insert_task(task_mark, v_id, mark, channel_id)  # 插入数据库
-                                current_time = datetime.now()
-                                formatted_time = current_time.strftime("%Y-%m-%d %H:%M:%S")
-                                sqlCollect.insert_machine_making_data(name, task_mark, channel_id, url, v_id, piaoquan_id, new_title, code, formatted_time, old_title, oss_object_key)
-                                if title == "原标题" or title == "AI标题":
-                                    values = [[name, task_mark, channel_id, url, str(v_id), piaoquan_id, old_title, title,new_title, str(code), formatted_time, str(rule)]]
-                                else:
-                                    values = [[name, task_mark, channel_id, url, str(v_id), piaoquan_id, old_title, "",new_title, str(code), formatted_time, str(rule)]]
-                                # 使用锁保护表格插入操作
-                                with lock:
-                                    if name == "王雪珂":
-                                        sheet = "vfhHwj"
-                                    elif name == "抖音品类账号-1":
-                                        sheet = "61kvW7"
-                                    elif name == "鲁涛":
-                                        sheet = "FhewlS"
-                                    elif name == "范军":
-                                        sheet = "B6dCfS"
-                                    elif name == "余海涛":
-                                        sheet = "mfBrNT"
-                                    elif name == "罗情":
-                                        sheet = "2J3PwN"
-                                    elif name == "王玉婷":
-                                        sheet = "bBHFwC"
-                                    elif name == "刘诗雨":
-                                        sheet = "fBdxIQ"
-                                    elif name == "信欣":
-                                        sheet = "lPe1eT"
-                                    elif name == "快手创作者版品类推荐流":
-                                        sheet = "k7l7nQ"
-                                    elif name == "抖音品类账号":
-                                        sheet = "Bsg5UR"
-                                    elif name == "视频号品类账号":
-                                        sheet = "b0uLWw"
-                                    Feishu.insert_columns("ILb4sa0LahddRktnRipcu2vQnLb", sheet, "ROWS", 1, 2)
-                                    time.sleep(0.5)
-                                    # time.sleep(random.randint(1, 2))
-                                    Feishu.update_values("ILb4sa0LahddRktnRipcu2vQnLb", sheet, "A2:Z2", values)
-                            else:
-                                Common.logger("warning").info(f"{name}的{task_mark}下的{url}视频{v_id} 视频发送票圈失败 {code}")
-                            cls.remove_files(video_path_url)
-                        else:
-                            cls.remove_files(video_path_url)
-                            Common.logger("warning").info(f"{name}的{task_mark}下的{url}视频{v_id} 视频发送OSS失败 ")
-                    Feishu.bot(mark, '机器自动改造消息通知', f'{task_mark}任务改造完成,请关注', name)
-                except Exception as e:
-                    cls.remove_files(video_path_url)
-                    Common.logger("warning").warning(f"{name}的{task_mark}任务处理失败:{e}\n")
-
-        batch_size = 1
-        with concurrent.futures.ThreadPoolExecutor(max_workers=batch_size) as executor:
-            index = 0
-            while index < len(task_data):
-                # 计算剩余的任务数量
-                remaining_tasks = len(task_data) - index
-                # 当前批次大小为剩余任务数量和批次大小中较小的一个
-                current_batch_size = min(batch_size, remaining_tasks)
-                # 获取当前批次的任务
-                current_batch = task_data[index:index + batch_size]
-                futures = {executor.submit(process_task, task): task for task in current_batch}
-                for future in concurrent.futures.as_completed(futures):
-                    task = futures[future]
-                    try:
-                        future.result()
-                        print(f"Task {task['task_mark']} 完成")
-                    except Exception as exc:
-                        Common.logger("warning").warning(f"{name}的{task['task_mark']}任务处理失败:{exc}\n")
-                        print(f"Task {task['task_mark']} 异常信息: {exc}")
-                # 移动到下一批任务
-                index += current_batch_size
-
-        Feishu.bot(mark, '机器自动改造消息通知', f'你的任务全部完成,请关注!!!!!', name)
-        return mark

+ 172 - 125
video_rewriting/video_processor.py

@@ -1,4 +1,5 @@
 import configparser
+import json
 import os
 import random
 import re
@@ -8,6 +9,7 @@ import time
 from datetime import datetime
 import concurrent.futures
 
+from common.redis import get_data
 from common.tts_help import TTS
 from common import Material, Feishu, Common, Oss
 from common.ffmpeg import FFmpeg
@@ -74,7 +76,7 @@ class VideoProcessor:
         """
         task_mark = task["task_mark"]
         channel_id = str(task["channel_id"])
-        channel_urls = str(task["channel_url"])
+        url = str(task["channel_url"])
         piaoquan_id = str(task["piaoquan_id"])
         number = task["number"]
         title = task["title"]
@@ -84,113 +86,155 @@ class VideoProcessor:
         gg_duration_total = task["gg_duration_total"]
         video_path_url = cls.create_folders(mark, str(task_mark))
         zm = Material.get_pzsrt_data("summary", "500Oe0", video_share)
-        # if not zm:
-        #     Feishu.bot(mark, '机器自动改造消息通知', f'{task_mark}任务下片中标示填写错误,请关注!!!!', name)
-        #     return
-        if ',' in channel_urls:
-            channel_url_list = channel_urls.split(',')
-        else:
-            channel_url_list = [channel_urls]
-        for url in channel_url_list:
-            Common.logger("log").info(f"{name}的{task_mark}下{channel_id}的用户:{channel_url_list}开始获取视频")
-            data_list = cls.get_data_list(channel_id, task_mark, url, number, mark, feishu_id, cookie_sheet, name)
-            if not data_list:
-                Common.logger("log").info(f"{name}的{task_mark}下{channel_id}的视频ID{url} 已经改造过了")
-                Feishu.bot(mark, '机器自动改造消息通知', f'{task_mark}任务下{channel_id}的用户ID{url},没有已经改造的视频了', name)
-                cls.remove_files(video_path_url)
-                continue
-            Common.logger("log").info(f"{name}的{task_mark}下的ID{url} 获取视频完成,共{len(data_list)}条")
-            for video in data_list:
-                try:
-                    new_title = cls.generate_title(video, title)
-                    v_id = video["video_id"]
-                    cover = video["cover"]
-                    video_url = video["video_url"]
-                    old_title = video['old_title']
-                    rule = video['rule']
+        Common.logger(mark).info(f"{name}的{task_mark}下{channel_id}的用户:{url}开始获取视频")
+        data_list = cls.get_data_list(channel_id, task_mark, url, number, mark, feishu_id, cookie_sheet, name)
+        if not data_list:
+            Common.logger(mark).info(f"{name}的{task_mark}下{channel_id}的视频ID{url} 已经改造过了")
+            text = (
+                f"**通知类型**: 没有改造的视频\n"
+                f"**负责人**: {name}\n"
+                f"**渠道**: {channel_id}\n"
+                f"**视频主页ID**: {url}\n"
+                f"**任务标示**: {task_mark}\n"
+            )
+            Feishu.finish_bot(text, "https://open.feishu.cn/open-apis/bot/v2/hook/e7697dc6-5254-4411-8b59-3cd0742bf703",
+                              "【 机器改造通知 】")
+            cls.remove_files(video_path_url)
+            return
+        Common.logger(mark).info(f"{name}的{task_mark}下的ID{url} 获取视频完成,共{len(data_list)}条")
+        for video in data_list:
+            try:
+                new_title = cls.generate_title(video, title)
+                v_id = video["video_id"]
+                cover = video["cover"]
+                video_url = video["video_url"]
+                old_title = video['old_title']
+                rule = video['rule']
+
+                if not old_title:
+                    old_title = '⭕分享给大家一个视频!值得细品!'
+                    text = (
+                        f"**通知类型**: 标题为空,使用兜底标题生成片尾\n"
+                        f"**负责人**: {name}\n"
+                        f"**渠道**: {channel_id}\n"
+                        f"**视频主页ID**: {url}\n"
+                        f"**视频Video_id**: {v_id}\n"
+                        f"**任务标示**: {task_mark}\n"
+                    )
+                    Feishu.finish_bot(text,
+                                      "https://open.feishu.cn/open-apis/bot/v2/hook/e7697dc6-5254-4411-8b59-3cd0742bf703",
+                                      "【 机器改造通知 】")
+                    Common.logger(mark).info(f"{name}的{task_mark}下的视频{url},标题为空,使用兜底标题生成片尾")
+                time.sleep(1)
+                pw_random_id = cls.random_id()
+                new_video_path = cls.download_and_process_video(channel_id, video_url, video_path_url, v_id,
+                                                                crop_total, gg_duration_total, pw_random_id, new_title, mark)
+                if not os.path.isfile(new_video_path):
+                    text = (
+                        f"**通知类型**: 视频下载失败\n"
+                        f"**负责人**: {name}\n"
+                        f"**渠道**: {channel_id}\n"
+                        f"**视频主页ID**: {url}\n"
+                        f"**视频Video_id**: {v_id}\n"
+                        f"**任务标示**: {task_mark}\n"
+                    )
+                    Feishu.finish_bot(text,
+                                      "https://open.feishu.cn/open-apis/bot/v2/hook/e7697dc6-5254-4411-8b59-3cd0742bf703",
+                                      "【 机器改造通知 】")
+                    cls.remove_files(video_path_url)
+                    continue
+                if new_video_path:
+                    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)
+                    else:
+                        if video_share and video_share != 'None':
+                            new_video_path = FFmpeg.single_video(new_video_path, video_path_url, zm)
+                            # new_video_path = FFmpeg.single_video(new_video_path, video_path_url, zm)
 
-                    if not old_title:
-                        old_title = '⭕分享给大家一个视频!值得细品!'
-                        Common.logger("title").info(f"{name}的{task_mark}下的视频{url},标题为空,使用兜底标题生成片尾")
-                    time.sleep(1)
-                    pw_random_id = cls.random_id()
-                    new_video_path = cls.download_and_process_video(channel_id, video_url, video_path_url, v_id,
-                                                                    crop_total, gg_duration_total, pw_random_id, new_title)
                     if not os.path.isfile(new_video_path):
-                        Feishu.bot(mark, '机器自动改造消息通知', f'{task_mark}任务用户{url}下的视频{v_id},视频下载失败,请关注', name)
+                        text = (
+                            f"**通知类型**: 视频改造失败\n"
+                            f"**负责人**: {name}\n"
+                            f"**渠道**: {channel_id}\n"
+                            f"**视频主页ID**: {url}\n"
+                            f"**视频Video_id**: {v_id}\n"
+                            f"**任务标示**: {task_mark}\n"
+                        )
+                        Feishu.finish_bot(text,
+                                          "https://open.feishu.cn/open-apis/bot/v2/hook/e7697dc6-5254-4411-8b59-3cd0742bf703",
+                                          "【 机器改造通知 】")
                         cls.remove_files(video_path_url)
                         continue
-                    if new_video_path:
-                        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)
-                        else:
-                            if video_share and video_share != 'None':
-                                new_video_path = FFmpeg.single_video(new_video_path, video_path_url, zm)
-                                # new_video_path = FFmpeg.single_video(new_video_path, video_path_url, zm)
-
-                        if not os.path.isfile(new_video_path):
-                            Feishu.bot(mark, '机器自动改造消息通知', f'{task_mark}任务用户{url}下的视频{v_id},视频改造失败,请关注', name)
-                            cls.remove_files(video_path_url)
-                            continue
-                        # 上传视频和封面,并更新数据库
-                        values, code = 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} 视频修改已使用,状态已修改")
-                                pq_url = f'https://admin.piaoquantv.com/cms/post-detail/{code}/detail' # 站内视频链接
-                                from_user_name = video['from_user_name']  # 来源用户
-                                from_group_name = video['from_group_name']  # 来源群组
-                                text = (
-                                    f"**站内视频链接**: {pq_url}\n"
-                                    f"**来源用户**: {from_user_name}\n"
-                                    f"**来源群组**: {from_group_name}\n"
-                                    f"**原视频链接**: {video['video_url']}\n"
-                                    f"**原视频封面**: {video['cover']}\n"
-                                    f"**原视频标题**: {video['old_title']}\n"
-                                )
-                                Feishu.finish_bot(text, "https://open.feishu.cn/open-apis/bot/v2/hook/0553124e-7fc1-4f9b-8976-9db4218d25e2", "【 有一条新的视频号内容改造成功 】")
+                    # 上传视频和封面,并更新数据库
+                    values, code = 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)
+                    # 更新已使用的视频号状态
+                    pq_url = f'https://admin.piaoquantv.com/cms/post-detail/{code}/detail'  # 站内视频链接
+                    if name == "视频号单视频":
+                        sphdd_status = sqlCollect.update_shp_dd_vid(v_id)
+                        if sphdd_status == 1:
+                            Common.logger(mark).info(f"{name}的{task_mark}下的ID{url} 视频修改已使用,状态已修改")
+                            from_user_name = video['from_user_name']  # 来源用户
+                            from_group_name = video['from_group_name']  # 来源群组
+                            text = (
+                                f"**站内视频链接**: {pq_url}\n"
+                                f"**来源用户**: {from_user_name}\n"
+                                f"**来源群组**: {from_group_name}\n"
+                                f"**原视频链接**: {video['video_url']}\n"
+                                f"**原视频封面**: {video['cover']}\n"
+                                f"**原视频标题**: {video['old_title']}\n"
+                            )
+                            Feishu.finish_bot(text, "https://open.feishu.cn/open-apis/bot/v2/hook/0553124e-7fc1-4f9b-8976-9db4218d25e2", "【 有一条新的视频号内容改造成功 】")
+                    text = (
+                        f"**通知类型**: 视频改造成功\n"
+                        f"**站内视频链接**: {pq_url}\n"
+                        f"**负责人**: {name}\n"
+                        f"**渠道**: {channel_id}\n"
+                        f"**视频主页ID**: {url}\n"
+                        f"**视频Video_id**: {v_id}\n"
+                        f"**任务标示**: {task_mark}\n"
+                    )
+                    Feishu.finish_bot(text,
+                                      "https://open.feishu.cn/open-apis/bot/v2/hook/e7697dc6-5254-4411-8b59-3cd0742bf703",
+                                      "【 机器改造通知 】")
+                    if values:
+                        if name == "王雪珂":
+                            sheet = "vfhHwj"
+                        elif name == "抖音品类账号-1":
+                            sheet = "61kvW7"
+                        elif name == "鲁涛":
+                            sheet = "FhewlS"
+                        elif name == "范军":
+                            sheet = "B6dCfS"
+                        elif name == "余海涛":
+                            sheet = "mfBrNT"
+                        elif name == "罗情":
+                            sheet = "2J3PwN"
+                        elif name == "王玉婷":
+                            sheet = "bBHFwC"
+                        elif name == "刘诗雨":
+                            sheet = "fBdxIQ"
+                        elif name == "信欣":
+                            sheet = "lPe1eT"
+                        elif name == "快手创作者版品类推荐流":
+                            sheet = "k7l7nQ"
+                        elif name == "抖音品类账号":
+                            sheet = "Bsg5UR"
+                        elif name == "视频号品类账号":
+                            sheet = "b0uLWw"
+                        elif name == "视频号单视频":
+                            sheet = "ptgCXW"
+                        elif name == "快手品类账号":
+                            sheet = "ibjoMx"
+                        Feishu.insert_columns("ILb4sa0LahddRktnRipcu2vQnLb", sheet, "ROWS", 1, 2)
+                        time.sleep(0.5)
+                        Feishu.update_values("ILb4sa0LahddRktnRipcu2vQnLb", sheet, "A2:Z2", values)
 
-                        if values:
-                            if name == "王雪珂":
-                                sheet = "vfhHwj"
-                            elif name == "抖音品类账号-1":
-                                sheet = "61kvW7"
-                            elif name == "鲁涛":
-                                sheet = "FhewlS"
-                            elif name == "范军":
-                                sheet = "B6dCfS"
-                            elif name == "余海涛":
-                                sheet = "mfBrNT"
-                            elif name == "罗情":
-                                sheet = "2J3PwN"
-                            elif name == "王玉婷":
-                                sheet = "bBHFwC"
-                            elif name == "刘诗雨":
-                                sheet = "fBdxIQ"
-                            elif name == "信欣":
-                                sheet = "lPe1eT"
-                            elif name == "快手创作者版品类推荐流":
-                                sheet = "k7l7nQ"
-                            elif name == "抖音品类账号":
-                                sheet = "Bsg5UR"
-                            elif name == "视频号品类账号":
-                                sheet = "b0uLWw"
-                            elif name == "视频号单视频":
-                                sheet = "ptgCXW"
-                            elif name == "快手品类账号":
-                                sheet = "ibjoMx"
-                            Feishu.insert_columns("ILb4sa0LahddRktnRipcu2vQnLb", sheet, "ROWS", 1, 2)
-                            time.sleep(0.5)
-                            Feishu.update_values("ILb4sa0LahddRktnRipcu2vQnLb", sheet, "A2:Z2", values)
 
-                except Exception as e:
-                    Common.logger("error").warning(f"{name}的{task_mark}任务处理失败:{e}")
-                    cls.remove_files(video_path_url)
-
-        Feishu.bot(mark, '机器自动改造消息通知', f'{task_mark}任务改造完成,请关注', name)
+            except Exception as e:
+                Common.logger(mark).warning(f"{name}的{task_mark}任务处理失败:{e}")
+                cls.remove_files(video_path_url)
+                return
 
     @classmethod
     def get_data_list(cls, channel_id, task_mark, url, number, mark, feishu_id, cookie_sheet, name):
@@ -210,7 +254,6 @@ class VideoProcessor:
         elif channel_id == "视频号单视频":
             return SPHDD.get_sphdd_data(url)
         elif channel_id == "抖音历史":
-            Common.logger("log").info(f"开始抓取{name}的{task_mark}下{channel_id}的视频ID{url} ")
             return DYLS.get_dyls_list(task_mark, url, number, mark)
         elif channel_id == "快手历史":
             return KSLS.get_ksls_list(task_mark, url, number, mark)
@@ -245,18 +288,18 @@ class VideoProcessor:
 
     @classmethod
     def download_and_process_video(cls, channel_id, video_url, video_path_url, v_id, crop_total, gg_duration_total,
-                                   pw_random_id, new_title):
+                                   pw_random_id, new_title, mark):
         """
         下载并处理视频
         """
         if channel_id in ["票圈", "快手创作者版"]:
             new_video_path = PQ.download_video(video_url, video_path_url, v_id)
-            Common.logger("log").info(f"{channel_id}视频下载成功: {new_video_path}")
+            Common.logger(mark).info(f"{channel_id}视频下载成功: {new_video_path}")
 
         else:
-            Common.logger("log").info(f"视频准备下载")
+            Common.logger(mark).info(f"视频准备下载")
             new_video_path = Oss.download_video_oss(video_url, video_path_url, v_id)
-            Common.logger("log").info(f"视频下载成功: {new_video_path}")
+            Common.logger(mark).info(f"视频下载成功: {new_video_path}")
 
         if os.path.isfile(new_video_path):
             if crop_total and crop_total != 'None':  # 判断是否需要裁剪
@@ -274,7 +317,7 @@ class VideoProcessor:
                 new_video_path = FFmpeg.add_video_zm(new_video_path, video_path_url, pw_random_id, new_title_re)
             return new_video_path
         else:
-            Common.logger("log").info(f"视频下载失败: {new_video_path}")
+            Common.logger(mark).info(f"视频下载失败: {new_video_path}")
             cls.remove_files(video_path_url)
             return new_video_path
 
@@ -291,13 +334,13 @@ class VideoProcessor:
                     pw_mp3_path = TTS.download_mp3(pw_url, video_path_url, pw_random_id)
                     # pw_url_sec = FFmpeg.get_video_duration(pw_mp3_path)
                     pw_srt = TTS.getSrt(pw_url)
-                    Common.logger("log").info(f"{name}的{task_mark}下的视频{url},获取AI片尾srt成功")
+                    Common.logger(mark).info(f"{name}的{task_mark}下的视频{url},获取AI片尾srt成功")
                 else:
                     Feishu.bot(mark, 'TTS获取失败提示', f'无法获取到片尾音频,及时更换token', "张勇")
-                    Common.logger("log").info(f"{name}的{task_mark}下的视频{url},获取AI片尾失败")
+                    Common.logger(mark).info(f"{name}的{task_mark}下的视频{url},获取AI片尾失败")
                     return None
             else:
-                Common.logger("log").info(f"{name}的{task_mark}下的视频{url},获取AI片尾失败")
+                Common.logger(mark).info(f"{name}的{task_mark}下的视频{url},获取AI片尾失败")
                 return None
         else:
             if ',' in video_ending:
@@ -316,21 +359,21 @@ class VideoProcessor:
         for attempt in range(3):
             jpg_path = FFmpeg.video_png(new_video_path, video_path_url, pw_random_id)  # 生成视频最后一帧jpg
             if os.path.isfile(jpg_path):
-                Common.logger("log").info(f"{name}的{task_mark}下的视频{url},生成视频最后一帧成功")
+                Common.logger(mark).info(f"{name}的{task_mark}下的视频{url},生成视频最后一帧成功")
                 break
             time.sleep(1)
         for attempt in range(3):
-            Common.logger("log").info(f"{name}的{task_mark}下的视频{url},获取mp3成功")
+            Common.logger(mark).info(f"{name}的{task_mark}下的视频{url},获取mp3成功")
             pw_path = FFmpeg.pw_video(jpg_path, video_path_url, pw_mp3_path, pw_srt, pw_random_id,
                                       pw_mp3_path)  # 生成片尾视频
             if os.path.isfile(pw_path):
-                Common.logger("log").info(f"{task_mark}下的视频{url},生成片尾视频成功")
+                Common.logger(mark).info(f"{task_mark}下的视频{url},生成片尾视频成功")
                 break
             time.sleep(1)
         pw_video_list = [new_video_path, pw_path]
-        Common.logger("log").info(f"{task_mark}下的视频{url},视频与片尾开始拼接")
+        Common.logger(mark).info(f"{task_mark}下的视频{url},视频与片尾开始拼接")
         video_path = FFmpeg.concatenate_videos(pw_video_list, video_path_url)  # 视频与片尾拼接到一起
-        Common.logger("log").info(f"{name}的{task_mark}下的视频{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)
@@ -349,9 +392,9 @@ class VideoProcessor:
         """
         try:
             oss_id = cls.random_id()
-            Common.logger("log").info(f"{name}的{task_mark},开始发送oss")
+            Common.logger(mark).info(f"{name}的{task_mark},开始发送oss")
             oss_object_key = Oss.stitching_sync_upload_oss(new_video_path, oss_id)  # 视频发送OSS
-            Common.logger("log").info(f"{name}的{task_mark},发送oss成功{oss_object_key}")
+            Common.logger(mark).info(f"{name}的{task_mark},发送oss成功{oss_object_key}")
             status = oss_object_key.get("status")
             if status == 200:
                 oss_object_key = oss_object_key.get("oss_object_key")
@@ -367,7 +410,7 @@ class VideoProcessor:
                 else:
                     jpg = None
                 code = PQ.insert_piaoquantv(oss_object_key, new_title, jpg, piaoquan_id)
-                Common.logger("log").info(f"{name}的{task_mark}下的视频ID{v_id}发送成功")
+                Common.logger(mark).info(f"{name}的{task_mark}下的视频ID{v_id}发送成功")
                 sqlCollect.insert_task(task_mark, v_id, mark, channel_id)  # 插入数据库
                 current_time = datetime.now()
                 formatted_time = current_time.strftime("%Y-%m-%d %H:%M:%S")
@@ -412,12 +455,16 @@ class VideoProcessor:
         feishu_sheet = data["feishu_sheet"]
         cookie_sheet = data["cookie_sheet"]
         task_data = Material.get_task_data(feishu_id, feishu_sheet)
-        for task in task_data:
-            try:
-                VideoProcessor.process_task(task, mark, name, feishu_id, cookie_sheet)
-            except Exception as e:
-                Common.logger("error").error(f"任务处理失败: {e}")
-                continue
+        data = get_data(mark, task_data)
+        if not data:
+            return
+        task = json.loads(data)
+        try:
+            VideoProcessor.process_task(task, name, feishu_id, cookie_sheet)
+            return mark
+        except Exception as e:
+            Common.logger(mark).error(f"任务处理失败: {e}")
+            return mark
 
 
 # if __name__ == "__main__":