zhangyong 4 ماه پیش
والد
کامیت
959c24420b
1فایلهای تغییر یافته به همراه14 افزوده شده و 12 حذف شده
  1. 14 12
      data_channel/piaoquan.py

+ 14 - 12
data_channel/piaoquan.py

@@ -286,7 +286,7 @@ class PQ:
             return url_video
             return url_video
         except Exception as e:
         except Exception as e:
             print(e)
             print(e)
-            return None
+            return url_video
 
 
     "视频号加密视频解密"
     "视频号加密视频解密"
     @classmethod
     @classmethod
@@ -379,14 +379,15 @@ class PQ:
                         if url_videos:
                         if url_videos:
                             url_video = url_videos
                             url_video = url_videos
                 if i == 3:
                 if i == 3:
-                    return None
-        return None
+                    return new_video
+        return new_video
 
 
     """
     """
     视频号视频下载
     视频号视频下载
     """
     """
     @classmethod
     @classmethod
     def sph_download_video(cls, video_url, video_path_url, video_id, video):
     def sph_download_video(cls, video_url, video_path_url, video_id, video):
+        new_video = video_path_url + str(video_id) + '.mp4'
         decode_key = int(video['decode_key'])
         decode_key = int(video['decode_key'])
         data, enc_length = None, 0
         data, enc_length = None, 0
         for i in range(3):
         for i in range(3):
@@ -400,9 +401,8 @@ class PQ:
             except TimeoutError:
             except TimeoutError:
                 continue
                 continue
         if not data:
         if not data:
-            return None
+            return new_video
         video_url = cls.decrypt_video(data=data, decode_key=decode_key, enc_length=enc_length)
         video_url = cls.decrypt_video(data=data, decode_key=decode_key, enc_length=enc_length)
-        new_video = video_path_url + str(video_id) + '.mp4'
         for i in range(3):
         for i in range(3):
             try:
             try:
                 with open(f"{new_video}", 'wb') as f:
                 with open(f"{new_video}", 'wb') as f:
@@ -410,11 +410,13 @@ class PQ:
                     return new_video
                     return new_video
             except Exception:
             except Exception:
                 if i == 3:
                 if i == 3:
-                    return None
+                    return new_video
 
 
     """票圈/快手创作者"""
     """票圈/快手创作者"""
     @classmethod
     @classmethod
     def download_video(cls, video_url, video_path_url, video_id):
     def download_video(cls, video_url, video_path_url, video_id):
+        video = video_path_url + str(video_id) + '.mp4'
+
         try:
         try:
             for i in range(3):
             for i in range(3):
                 payload = {}
                 payload = {}
@@ -422,7 +424,6 @@ class PQ:
                 response = requests.request("GET", video_url, headers=headers, data=payload)
                 response = requests.request("GET", video_url, headers=headers, data=payload)
                 if response.status_code == 200:
                 if response.status_code == 200:
                     # 以二进制写入模式打开文件
                     # 以二进制写入模式打开文件
-                    video = video_path_url + str(video_id) + '.mp4'
                     with open(f"{video}", "wb") as file:
                     with open(f"{video}", "wb") as file:
                         # 将响应内容写入文件
                         # 将响应内容写入文件
                         file.write(response.content)
                         file.write(response.content)
@@ -430,13 +431,14 @@ class PQ:
                     return video
                     return video
             return None
             return None
         except Exception:
         except Exception:
-            return None
+            return video
 
 
     """抖音"""
     """抖音"""
     @classmethod
     @classmethod
     def download_dy_video(cls, video_url, video_path_url, video_id):
     def download_dy_video(cls, video_url, video_path_url, video_id):
+        video = video_path_url + str(video_id) + '.mp4'
+
         try:
         try:
-            video = video_path_url + str(video_id) + '.mp4'
             for i in range(3):
             for i in range(3):
                 payload = {}
                 payload = {}
                 headers = {
                 headers = {
@@ -462,27 +464,27 @@ class PQ:
             return video
             return video
         except Exception as e:
         except Exception as e:
             print(e)
             print(e)
-            return None
+            return video
 
 
     """
     """
     票圈站内视频下载
     票圈站内视频下载
     """
     """
     @classmethod
     @classmethod
     def download_video_jpg(cls, video_url, video_path_url, video_id):
     def download_video_jpg(cls, video_url, video_path_url, video_id):
+        video = video_path_url + str(video_id) + '.jpg'
         try:
         try:
             payload = {}
             payload = {}
             headers = {}
             headers = {}
             response = requests.request("GET", video_url, headers=headers, data=payload)
             response = requests.request("GET", video_url, headers=headers, data=payload)
             if response.status_code == 200:
             if response.status_code == 200:
                 # 以二进制写入模式打开文件
                 # 以二进制写入模式打开文件
-                video = video_path_url + str(video_id) + '.jpg'
                 with open(f"{video}", "wb") as file:
                 with open(f"{video}", "wb") as file:
                     # 将响应内容写入文件
                     # 将响应内容写入文件
                     file.write(response.content)
                     file.write(response.content)
                 time.sleep(5)
                 time.sleep(5)
                 return video
                 return video
         except Exception:
         except Exception:
-            return None
+            return video
 
 
 
 
 if __name__ == '__main__':
 if __name__ == '__main__':