Explorar o código

抖音快手视频号 增加规则

zhangyong hai 9 meses
pai
achega
cd88b21406

+ 41 - 0
douyin/douyin_author/douyin_author_scheduling_new.py

@@ -5,6 +5,7 @@ import random
 import sys
 import time
 
+import cv2
 import requests
 import json
 import urllib3
@@ -173,6 +174,36 @@ class DouyinauthorScheduling:
                         comment_count = int(data[i].get('statistics').get('comment_count'))  # 评论
                         # collect_count = data[i].get('statistics').get('collect_count')  # 收藏
                         share_count = int(data[i].get('statistics').get('share_count'))  # 转发
+                        if share_count < 500:
+                            AliyunLogger.logging(
+                                code="2004",
+                                platform=crawler,
+                                mode=log_type,
+                                env=env,
+                                message=f'分享小于500\n'
+                            )
+                            continue
+                        video_percent = '%.2f' % (share_count / digg_count)
+                        special = float(0.25)
+                        if float(video_percent) < special:
+                            AliyunLogger.logging(
+                                code="2004",
+                                platform=crawler,
+                                mode=log_type,
+                                env=env,
+                                message=f'分享/点赞小于25%\n'
+                            )
+                            continue
+                        duration = cls.video_duration(video_url)
+                        if int(duration) < 45:
+                            AliyunLogger.logging(
+                                code="2004",
+                                platform=crawler,
+                                mode=log_type,
+                                env=env,
+                                message=f'视频时常小于45秒\n'
+                            )
+                            continue
                         # if special != 0:
                         #     if share_count != 0:
                         #         video_percent = '%.2f' % (share_count / digg_count)
@@ -328,6 +359,16 @@ class DouyinauthorScheduling:
                     message=f"抓取用户{user_dict['nick_name']}主页视频时异常:{e}\n"
                 )
 
+    @classmethod
+    def video_duration(cls, filename):
+        cap = cv2.VideoCapture(filename)
+        if cap.isOpened():
+            rate = cap.get(5)
+            frame_num = cap.get(7)
+            duration = frame_num / rate
+            return duration
+        return 0
+
 
 if __name__ == "__main__":
     print(DouyinauthorScheduling.get_cookie("author", "douyin", "prod")["cookie"])

+ 31 - 0
kuaishou/kuaishou_author/kuaishou_author_scheduling_new.py

@@ -6,6 +6,8 @@ import random
 import sys
 import time
 from datetime import date, timedelta
+
+import cv2
 import requests
 import json
 import urllib3
@@ -244,6 +246,25 @@ class KuaishouauthorScheduling:
 
                     viewCount = int(feeds[i].get('photo', {}).get('viewCount', 0))
                     realLikeCount = int(feeds[i].get('photo', {}).get('realLikeCount', 0))
+                    if realLikeCount < 10000:
+                        AliyunLogger.logging(
+                            code="2004",
+                            platform=crawler,
+                            mode=log_type,
+                            env=env,
+                            message=f'点赞小于10000\n'
+                        )
+                        continue
+                    duration = cls.video_duration(feeds[i].get('photo', {}).get('photoUrl', ""))
+                    if int(duration) < 45:
+                        AliyunLogger.logging(
+                            code="2004",
+                            platform=crawler,
+                            mode=log_type,
+                            env=env,
+                            message=f'视频时常小于45秒\n'
+                        )
+                        continue
                     # video_percent = '%.2f' % (realLikeCount / viewCount)
                     # if special != 0:
                     #     special = float(special)
@@ -412,6 +433,16 @@ class KuaishouauthorScheduling:
                     message=f"抓取用户{user_dict['nick_name']}主页视频时异常:{e}\n"
                 )
 
+    @classmethod
+    def video_duration(cls, filename):
+        cap = cv2.VideoCapture(filename)
+        if cap.isOpened():
+            rate = cap.get(5)
+            frame_num = cap.get(7)
+            duration = frame_num / rate
+            return duration
+        return 0
+
 
 if __name__ == "__main__":
     print(KuaishouauthorScheduling.get_cookie("author", "kuaishou", "prod")["cookie"])

+ 8 - 43
shipinhao/shipinhao_author/shipinhao_author.py

@@ -241,8 +241,15 @@ class ShiPinHaoAuthor(object):
             divisor_cnt = 0
         else:
             divisor_cnt = int(share_cnt / fav_count)
+        if share_cnt < 500:
+            return True
+        video_percent = '%.2f' % (share_cnt / like_cnt)
+        special = float(0.25)
+        if float(video_percent) < special:
+
+            return True
         # 视频时长小于30秒 返回
-        if duration < 15:
+        if duration < 45:
             values = [[
                 obj['nickname'],
                 publish_time_str,
@@ -262,48 +269,6 @@ class ShiPinHaoAuthor(object):
             time.sleep(0.5)
             Feishu.update_values(self.platform, 'shipinhao', "Vq7NeH", "A2:Z2", values)
             return True
-        # # 分享小于1000 返回
-        # if share_cnt < 500:
-        #     values = [[
-        #         obj['nickname'],
-        #         publish_time_str,
-        #         formatted_time,
-        #         int(obj['fav_count']),
-        #         int(obj['comment_count']),
-        #         int(obj['like_count']),
-        #         int(obj['forward_count']),
-        #         divisor_cnt,
-        #         video_obj.get('title').split("\n")[0].split("#")[0],
-        #         duration,
-        #         '否',
-        #         '分享小于500',
-        #         video_obj.get('DownloadAddress')
-        #     ]]
-        #     Feishu.insert_columns(self.platform, 'shipinhao', "Vq7NeH", "ROWS", 1, 2)
-        #     time.sleep(0.5)
-        #     Feishu.update_values(self.platform, 'shipinhao', "Vq7NeH", "A2:Z2", values)
-        #     return True
-        # # 分享小于等于99999
-        # if share_cnt <= 99999 and divisor_cnt < 1:
-        #     values = [[
-        #         obj['nickname'],
-        #         publish_time_str,
-        #         formatted_time,
-        #         int(obj['fav_count']),
-        #         int(obj['comment_count']),
-        #         int(obj['like_count']),
-        #         int(obj['forward_count']),
-        #         divisor_cnt,
-        #         video_obj.get('title').split("\n")[0].split("#")[0],
-        #         duration,
-        #         '否',
-        #         f'分享小于100000,分享/大拇指:{divisor_cnt}',
-        #         video_obj.get('DownloadAddress')
-        #     ]]
-        #     Feishu.insert_columns(self.platform, 'shipinhao', "Vq7NeH", "ROWS", 1, 2)
-        #     time.sleep(0.5)
-        #     Feishu.update_values(self.platform, 'shipinhao', "Vq7NeH", "A2:Z2", values)
-        #     return True
         pipeline = PiaoQuanPipeline(
             platform=self.platform,
             mode=self.mode,