Procházet zdrojové kódy

增加视频号下载失败处理

zhangyong před 7 měsíci
rodič
revize
bb5fb0bde7
2 změnil soubory, kde provedl 20 přidání a 4 odebrání
  1. 2 2
      common/sql_help.py
  2. 18 2
      data_channel/piaoquan.py

+ 2 - 2
common/sql_help.py

@@ -198,11 +198,11 @@ class sqlCollect():
         return res
 
     @classmethod
-    def update_shp_dd_vid_1(cls, vid):
+    def update_shp_dd_vid_4(cls, vid):
         """
         视频号单点修改状态为2
         """
-        sql = f"""UPDATE dandian_content set has_used = 2 where video_id = '{vid}'"""
+        sql = f"""UPDATE dandian_content set has_used = 4 where video_id = '{vid}'"""
         res = AigcMysqlHelper.update_values(
             sql=sql
         )

+ 18 - 2
data_channel/piaoquan.py

@@ -7,7 +7,7 @@ import cffi
 import requests
 from urllib.parse import urlencode
 
-from common import Common, AliyunLogger
+from common import Common, AliyunLogger, Feishu
 from common.sql_help import sqlCollect
 
 
@@ -314,7 +314,7 @@ class PQ:
                 data, enc_length = None, 0
                 for i in range(3):
                     try:
-                        response = requests.get(url=video_url, timeout=5)
+                        response = requests.get(url=video_url, timeout=10)
                         data = response.content
                         data_length = int(response.headers.get("Content-Range", 0))
                         enc_length = int(response.headers.get('X-enclen', 131072))
@@ -323,6 +323,22 @@ class PQ:
                     except TimeoutError:
                         continue
                 if not data:
+                    v_id = video["video_id"]
+                    sqlCollect.update_shp_dd_vid_4(v_id)
+                    from_user_name = video['from_user_name']  # 来源用户
+                    from_group_name = video['from_group_name']  # 来源群组
+                    source = video['source']  # 渠道
+                    text = (
+                        f"**渠道**: {source}\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/493b3d4c-5fae-4a9d-980b-1dd86636524e",
+                                      "【 视频下载失败 】")
                     return None
                 video_url = cls.decrypt_video(data=data, decode_key=decode_key, enc_length=enc_length)