zhangyong 5 months ago
parent
commit
ce571897fe
3 changed files with 18 additions and 15 deletions
  1. 10 10
      carry_data_handle.py
  2. 5 5
      carry_data_redis.py
  3. 3 0
      common/download_video.py

+ 10 - 10
carry_data_handle.py

@@ -28,16 +28,16 @@ def video_task_start():
         mark = carry_video.main(json.loads(data), REDIS_NAME, file_path)
         print(f"返回用户名: {mark}")
         logger.info(f"[+] {NAME}处理一条成功")
-        for filename in os.listdir(CACHE_DIR):
-            # 检查文件名是否包含关键字
-            if uid in filename:
-                file_path = os.path.join(CACHE_DIR, filename)
-                try:
-                    # 删除文件
-                    os.remove(file_path)
-                    logger.info(f"已删除文件: {file_path}")
-                except Exception as e:
-                    logger.error(f"删除文件时出错: {file_path}, 错误: {e}")
+        # for filename in os.listdir(CACHE_DIR):
+        #     # 检查文件名是否包含关键字
+        #     if uid in filename:
+        #         file_path = os.path.join(CACHE_DIR, filename)
+        #         try:
+        #             # 删除文件
+        #             os.remove(file_path)
+        #             logger.info(f"已删除文件: {file_path}")
+        #         except Exception as e:
+        #             logger.error(f"删除文件时出错: {file_path}, 错误: {e}")
     except Exception as e:
         data = json.loads(data)
         text = (

+ 5 - 5
carry_data_redis.py

@@ -29,9 +29,9 @@ def schedule_tasks():
 
 
 if __name__ == "__main__":
-    schedule_tasks()  # 调用任务调度函数
-    while True:
-        schedule.run_pending()
-        time.sleep(1)  # 每秒钟检查一次
-    # bot_carry_data()
+    # schedule_tasks()  # 调用任务调度函数
+    # while True:
+    #     schedule.run_pending()
+    #     time.sleep(1)  # 每秒钟检查一次
+    bot_carry_data()
 

+ 3 - 0
common/download_video.py

@@ -3,6 +3,7 @@ import subprocess
 import time
 
 import requests
+from loguru import logger
 
 
 class DownLoad:
@@ -11,9 +12,11 @@ class DownLoad:
         video = video_path_url + 'video.mp4'
         url_type = html.unescape(video_url).split('?')[0]
         if ".m3u8" in url_type:
+            logger.info(f"[+] {video_url}开始下载m3u8格式的视频")
             ffmpeg_cmd_oss = [
                 "ffmpeg",
                 "-y",  # 覆盖输出文件
+                "-protocol_whitelist", "file,http,https,tcp,tls",
                 "-i", video_url,  # 输入文件
                 "-c", "copy",  # 复制视频流
                 "-bsf:a", "aac_adtstoasc",  # 转换 AAC 音频格式