wangkun %!s(int64=2) %!d(string=hai) anos
pai
achega
fbf76ef308
Modificáronse 1 ficheiros con 18 adicións e 25 borrados
  1. 18 25
      gongzhonghao/gongzhonghao_follow/gongzhonghao_follow.py

+ 18 - 25
gongzhonghao/gongzhonghao_follow/gongzhonghao_follow.py

@@ -333,35 +333,28 @@ class GongzhonghaoFollow:
             Common.download_method(log_type=log_type, crawler=crawler, text="video",
                                    title=video_dict["video_title"], url=video_dict["video_url"])
             md_title = md5(video_dict['video_title'].encode('utf8')).hexdigest()
-            if os.path.getsize(f"./{crawler}/videos/{md_title}/video.mp4") == 0:
+            # 获取视频时长
+            ffmpeg_dict = Common.ffmpeg(log_type, crawler,
+                                        f"./{crawler}/videos/{video_dict['video_title']}/video.mp4")
+            if ffmpeg_dict is None:
+                # 删除视频文件夹
+                shutil.rmtree(f"./{crawler}/videos/{md_title}")
+                Common.logger(log_type, crawler).info("视频size=0,删除成功\n")
+                return
+            video_dict["video_width"] = ffmpeg_dict["width"]
+            video_dict["video_height"] = ffmpeg_dict["height"]
+            video_dict["duration"] = ffmpeg_dict["duration"]
+            video_size = ffmpeg_dict["size"]
+            Common.logger(log_type, crawler).info(f'video_width:{video_dict["video_width"]}')
+            Common.logger(log_type, crawler).info(f'video_height:{video_dict["video_height"]}')
+            Common.logger(log_type, crawler).info(f'duration:{video_dict["duration"]}')
+            Common.logger(log_type, crawler).info(f'video_size:{video_size}')
+            # 视频size=0,直接删除
+            if int(video_size) == 0 or cls.download_rule(video_dict) is False:
                 # 删除视频文件夹
                 shutil.rmtree(f"./{crawler}/videos/{md_title}")
                 Common.logger(log_type, crawler).info("视频size=0,删除成功\n")
                 return
-            # # 获取视频时长
-            # ffmpeg_dict = Common.ffmpeg(log_type, crawler,
-            #                             f"./{crawler}/videos/{video_dict['video_title']}/video.mp4")
-            # if ffmpeg_dict is None:
-            #     # 删除视频文件夹
-            #     md_title = md5(video_dict['video_title'].encode('utf8')).hexdigest()
-            #     shutil.rmtree(f"./{crawler}/videos/{md_title}")
-            #     Common.logger(log_type, crawler).info("视频size=0,删除成功\n")
-            #     return
-            # video_dict["video_width"] = ffmpeg_dict["width"]
-            # video_dict["video_height"] = ffmpeg_dict["height"]
-            # video_dict["duration"] = ffmpeg_dict["duration"]
-            # video_size = ffmpeg_dict["size"]
-            # Common.logger(log_type, crawler).info(f'video_width:{video_dict["video_width"]}')
-            # Common.logger(log_type, crawler).info(f'video_height:{video_dict["video_height"]}')
-            # Common.logger(log_type, crawler).info(f'duration:{video_dict["duration"]}')
-            # Common.logger(log_type, crawler).info(f'video_size:{video_size}')
-            # # 视频size=0,直接删除
-            # if int(video_size) == 0 or cls.download_rule(video_dict) is False:
-            #     # 删除视频文件夹
-            #     md_title = md5(video_dict['video_title'].encode('utf8')).hexdigest()
-            #     shutil.rmtree(f"./{crawler}/videos/{md_title}")
-            #     Common.logger(log_type, crawler).info("视频size=0,删除成功\n")
-            #     return
             # 下载封面
             Common.download_method(log_type=log_type, crawler=crawler, text="cover",
                                    title=video_dict["video_title"], url=video_dict["cover_url"])