zhangyong 5 months ago
parent
commit
8c2b7baf74
4 changed files with 29 additions and 22 deletions
  1. 5 5
      Dockerfile
  2. 6 5
      carry_data_handle.py
  3. 5 5
      carry_data_redis.py
  4. 13 7
      carry_video/carry_video.py

+ 5 - 5
Dockerfile

@@ -9,11 +9,11 @@ ENV TZ=Asia/Shanghai
 RUN apt update && apt --no-install-recommends install -y wget xz-utils nscd libgl-dev libglib2.0-dev fonts-wqy-zenhei \
     && apt-get clean && rm -rf /var/lib/apt/lists/* \
     && pip install -r requirements.txt --no-cache-dir \
-    && wget -O /tmp/ffmpeg-6.0.1-amd64-static.tar.xz https://www.johnvansickle.com/ffmpeg/old-releases/ffmpeg-6.0.1-amd64-static.tar.xz \
-    && tar -xJvf /tmp/ffmpeg-6.0.1-amd64-static.tar.xz -C /usr/local/ \
-    && rm /tmp/ffmpeg-6.0.1-amd64-static.tar.xz \
-    && ln -s /usr/local/ffmpeg-6.0.1-amd64-static/ffprobe /usr/local/bin/ffprobe \
-    && ln -s /usr/local/ffmpeg-6.0.1-amd64-static/ffmpeg /usr/local/bin/ffmpeg \
+    && wget -O /tmp/ffmpeg-7.0.2-amd64-static.tar.xz https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz \
+    && tar -xJvf /tmp/ffmpeg-7.0.2-amd64-static.tar.xz -C /usr/local/ \
+    && rm /tmp/ffmpeg-7.0.2-amd64-static.tar.xz \
+    && ln -s /usr/local/ffmpeg-7.0.2-amd64-static/ffprobe /usr/local/bin/ffprobe \
+    && ln -s /usr/local/ffmpeg-7.0.2-amd64-static/ffmpeg /usr/local/bin/ffmpeg \
     && mkdir -p /app/cache
 
 ENTRYPOINT ["python", "/app/carry_data_redis.py"]

+ 6 - 5
carry_data_handle.py

@@ -8,6 +8,7 @@ from loguru import logger
 
 from carry_video.carry_video import CarryViode
 from common import Feishu, AliyunLogger
+from common.ffmpeg import FFmpeg
 from common.redis import get_carry_data
 
 ENV = os.getenv('ENV', 'dev')
@@ -56,8 +57,8 @@ def schedule_tasks():
     schedule.every(4).minutes.do(video_task_start)
 
 if __name__ == '__main__':
-    # schedule_tasks()  # 调用任务调度函数
-    # while True:
-    #     schedule.run_pending()
-    #     time.sleep(1)  # 每秒钟检查一次
-    video_task_start()
+    schedule_tasks()  # 调用任务调度函数
+    while True:
+        schedule.run_pending()
+        time.sleep(1)  # 每秒钟检查一次
+    # video_task_start()

+ 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()
 

+ 13 - 7
carry_video/carry_video.py

@@ -85,14 +85,20 @@ class CarryViode:
             headers = {
                 'Content-Type': 'application/json'
             }
+            video_url = None
+            original_title = None
+            for i in range(3):
+                response = requests.request("POST", url, headers=headers, data=payload)
+                response = response.json()
+                code = response["code"]
+                if code == 0:
+                    data = response["data"]["data"]
 
-            response = requests.request("POST", url, headers=headers, data=payload)
-            response = response.json()
-            code = response["code"]
-            if code == 0:
-                data = response["data"]["data"]
-                video_url = data["video_url_list"][0]["video_url"]
-                original_title = data["title"]
+                    video_url = data["video_url_list"][0]["video_url"]
+                    original_title = data["title"]
+                    if ".mp4" in video_url:
+                        return video_url, original_title
+            if video_url:
                 return video_url, original_title
             else:
                 return None,None