|  | @@ -47,7 +47,6 @@ class Follow:
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @classmethod
 | 
	
		
			
				|  |  |      def start_follow_wechat(cls, log_type, user_name, env):
 | 
	
		
			
				|  |  | -        # try:
 | 
	
		
			
				|  |  |          Common.logger(log_type).info('启动微信')
 | 
	
		
			
				|  |  |          caps = {
 | 
	
		
			
				|  |  |              "platformName": "Android",  # 手机操作系统 Android / iOS
 | 
	
	
		
			
				|  | @@ -83,9 +82,6 @@ class Follow:
 | 
	
		
			
				|  |  |          time.sleep(3)
 | 
	
		
			
				|  |  |          cls.quit(log_type, driver)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        # except Exception as e:
 | 
	
		
			
				|  |  | -        #     Common.logger(log_type).error('start_follow_wechat异常:{}\n', e)
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      @classmethod
 | 
	
		
			
				|  |  |      def quit(cls, log_type, driver: WebDriver):
 | 
	
		
			
				|  |  |          driver.quit()
 | 
	
	
		
			
				|  | @@ -144,14 +140,14 @@ class Follow:
 | 
	
		
			
				|  |  |          driver.switch_to.context('NATIVE_APP')
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          # 判断置顶视频
 | 
	
		
			
				|  |  | -        top_videos = driver.find_elements(By.ID, 'com.tencent.mm:id/i56')
 | 
	
		
			
				|  |  | +        top_videos = driver.find_elements(By.ID, 'com.tencent.mm:id/e5s')
 | 
	
		
			
				|  |  |          Common.logger(log_type).info(f'发现 {len(top_videos)} 个置顶视频\n')
 | 
	
		
			
				|  |  |          if len(top_videos) == 0:
 | 
	
		
			
				|  |  |              Common.logger(log_type).info('当前用户没有置顶视频')
 | 
	
		
			
				|  |  |          else:
 | 
	
		
			
				|  |  |              for i in range(len(top_videos)):
 | 
	
		
			
				|  |  |                  top_videos[i].click()
 | 
	
		
			
				|  |  | -                cls.download_publish(log_type, driver, env)
 | 
	
		
			
				|  |  | +                cls.get_video_info(log_type, driver, env)
 | 
	
		
			
				|  |  |                  driver.press_keycode(AndroidKey.BACK)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          # 判断非置顶视频
 | 
	
	
		
			
				|  | @@ -160,14 +156,14 @@ class Follow:
 | 
	
		
			
				|  |  |          not_top_first_video = not_top_videos[len(top_videos)]
 | 
	
		
			
				|  |  |          not_top_first_video.click()
 | 
	
		
			
				|  |  |          while True:
 | 
	
		
			
				|  |  | -            cls.download_publish(log_type, driver, env)
 | 
	
		
			
				|  |  | +            cls.get_video_info(log_type, driver, env)
 | 
	
		
			
				|  |  |              driver.swipe(10, 1600, 10, 300, 200)
 | 
	
		
			
				|  |  |              if len(driver.find_elements(By.ID, 'com.tencent.mm:id/g2s')) > 0:
 | 
	
		
			
				|  |  |                  Common.logger(log_type).info('到底啦 ~\n')
 | 
	
		
			
				|  |  |                  return
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @classmethod
 | 
	
		
			
				|  |  | -    def get_video_info(cls, log_type, driver: WebDriver):
 | 
	
		
			
				|  |  | +    def get_video_info(cls, log_type, driver: WebDriver, env):
 | 
	
		
			
				|  |  |          driver.implicitly_wait(10)
 | 
	
		
			
				|  |  |          # 视频标题
 | 
	
		
			
				|  |  |          try:
 | 
	
	
		
			
				|  | @@ -249,79 +245,98 @@ class Follow:
 | 
	
		
			
				|  |  |          Common.logger(log_type).info('comment_cnt:{}', comment_cnt)
 | 
	
		
			
				|  |  |          Common.logger(log_type).info('user_name:{}', user_name)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        video_dict = {
 | 
	
		
			
				|  |  | -            'video_title': video_title,
 | 
	
		
			
				|  |  | -            'duration': duration,
 | 
	
		
			
				|  |  | -            'like_cnt': like_cnt,
 | 
	
		
			
				|  |  | -            'share_cnt': share_cnt,
 | 
	
		
			
				|  |  | -            'share_id': share_id,
 | 
	
		
			
				|  |  | -            'favorite_cnt': favorite_cnt,
 | 
	
		
			
				|  |  | -            'comment_cnt': comment_cnt,
 | 
	
		
			
				|  |  | -            'user_name': user_name
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        return video_dict
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    @classmethod
 | 
	
		
			
				|  |  | -    def download_publish(cls, log_type, driver: WebDriver, env):
 | 
	
		
			
				|  |  | -        video_dict = cls.get_video_info(log_type, driver)
 | 
	
		
			
				|  |  | -        Common.logger(log_type).info(f'video_dict:{video_dict}')
 | 
	
		
			
				|  |  | -        Common.logger(log_type).info(f'video_title:{video_dict["video_title"]}')
 | 
	
		
			
				|  |  | -        return
 | 
	
		
			
				|  |  | -        if int(video_dict['duration']) < 50:
 | 
	
		
			
				|  |  | -            Common.logger(log_type).info(f'时长:{int(video_dict["duration"])} < 50 秒\n')
 | 
	
		
			
				|  |  | -        elif video_dict['video_title'] == '':
 | 
	
		
			
				|  |  | +        if int(duration) < 50:
 | 
	
		
			
				|  |  | +            Common.logger(log_type).info(f'时长:{int(duration)} < 50 秒\n')
 | 
	
		
			
				|  |  | +        elif video_title == '':
 | 
	
		
			
				|  |  |              Common.logger(log_type).info('视频标题为空\n')
 | 
	
		
			
				|  |  |          # 过滤词库(视频标题)
 | 
	
		
			
				|  |  | -        elif any(word if word in video_dict['video_title'] else False for word in cls.filter_words(log_type)) is True:
 | 
	
		
			
				|  |  | -            Common.logger(log_type).info(f'视频已中过滤词:{video_dict["video_title"]}\n')
 | 
	
		
			
				|  |  | +        elif any(word if word in video_title else False for word in cls.filter_words(log_type)) is True:
 | 
	
		
			
				|  |  | +            Common.logger(log_type).info(f'视频已中过滤词:{video_title}\n')
 | 
	
		
			
				|  |  |          # 视频号推荐_已下载表
 | 
	
		
			
				|  |  | -        elif str(video_dict['video_title']) in [x for y in Feishu.get_values_batch(log_type, 'shipinhao', 'c77cf9') for x in y]:
 | 
	
		
			
				|  |  | +        elif video_title in [x for y in Feishu.get_values_batch(log_type, 'shipinhao', 'c77cf9') for x in y]:
 | 
	
		
			
				|  |  |              Common.logger(log_type).info('视频已下载\n')
 | 
	
		
			
				|  |  |          # 视频号定向_已下载表
 | 
	
		
			
				|  |  | -        elif str(video_dict['video_title']) in [x for y in Feishu.get_values_batch(log_type, 'shipinhao', 'XxmRlE') for x in y]:
 | 
	
		
			
				|  |  | +        elif video_title in [x for y in Feishu.get_values_batch(log_type, 'shipinhao', 'XxmRlE') for x in y]:
 | 
	
		
			
				|  |  |              Common.logger(log_type).info('视频已下载\n')
 | 
	
		
			
				|  |  |          # feeds 表去重
 | 
	
		
			
				|  |  | -        elif str(video_dict['video_title']) in [x for y in Feishu.get_values_batch(log_type, 'shipinhao', 'FSDlBy') for x in y]:
 | 
	
		
			
				|  |  | +        elif video_title in [x for y in Feishu.get_values_batch(log_type, 'shipinhao', 'FSDlBy') for x in y]:
 | 
	
		
			
				|  |  |              Common.logger(log_type).info('视频已存在\n')
 | 
	
		
			
				|  |  |          # feeds 表去重
 | 
	
		
			
				|  |  | -        elif str(video_dict['video_title']) in [x for y in Feishu.get_values_batch(log_type, 'shipinhao', 'qzDljJ') for x in y]:
 | 
	
		
			
				|  |  | +        elif video_title in [x for y in Feishu.get_values_batch(log_type, 'shipinhao', 'qzDljJ') for x in y]:
 | 
	
		
			
				|  |  |              Common.logger(log_type).info('视频已存在\n')
 | 
	
		
			
				|  |  |          # 分享给 windows 爬虫机
 | 
	
		
			
				|  |  |          else:
 | 
	
		
			
				|  |  | -            video_dict['share_id'].click()
 | 
	
		
			
				|  |  | -            driver.find_element(By.XPATH, '//*[@text="转发给朋友"]').click()
 | 
	
		
			
				|  |  | -            driver.find_element(By.XPATH, '//*[@text="爬虫群"]').click()
 | 
	
		
			
				|  |  | -            driver.find_element(By.ID, 'com.tencent.mm:id/guw').click()
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            # 把视频信息写入飞书feeds文档
 | 
	
		
			
				|  |  | -            Feishu.insert_columns(log_type, 'shipinhao', 'qzDljJ', 'ROWS', 1, 2)
 | 
	
		
			
				|  |  | -            get_feeds_time = int(time.time())
 | 
	
		
			
				|  |  | -            values = [[time.strftime('%Y/%m/%d %H:%M:%S', time.localtime(get_feeds_time)),
 | 
	
		
			
				|  |  | -                       '定向榜',
 | 
	
		
			
				|  |  | -                       str(video_dict['video_title']),
 | 
	
		
			
				|  |  | -                       int(video_dict['duration']),
 | 
	
		
			
				|  |  | -                       int(video_dict['like_cnt']),
 | 
	
		
			
				|  |  | -                       int(video_dict['share_cnt']),
 | 
	
		
			
				|  |  | -                       int(video_dict['favorite_cnt']),
 | 
	
		
			
				|  |  | -                       int(video_dict['comment_cnt']),
 | 
	
		
			
				|  |  | -                       str(video_dict['user_name'])]]
 | 
	
		
			
				|  |  | -            time.sleep(1)
 | 
	
		
			
				|  |  | -            Feishu.update_values(log_type, 'shipinhao', 'qzDljJ', 'A2:Z2', values)
 | 
	
		
			
				|  |  | -            Common.logger(log_type).info('视频信息写入飞书文档成功\n')
 | 
	
		
			
				|  |  | +            video_dict = {
 | 
	
		
			
				|  |  | +                'video_title': video_title,
 | 
	
		
			
				|  |  | +                'duration': duration,
 | 
	
		
			
				|  |  | +                'like_cnt': like_cnt,
 | 
	
		
			
				|  |  | +                'share_cnt': share_cnt,
 | 
	
		
			
				|  |  | +                'share_id': share_id,
 | 
	
		
			
				|  |  | +                'favorite_cnt': favorite_cnt,
 | 
	
		
			
				|  |  | +                'comment_cnt': comment_cnt,
 | 
	
		
			
				|  |  | +                'user_name': user_name
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            cls.share_to_windows(log_type, driver, video_dict, env)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            while True:
 | 
	
		
			
				|  |  | -                if Feishu.get_values_batch(log_type, 'shipinhao', 'qzDljJ')[1][11] is None:
 | 
	
		
			
				|  |  | -                    Common.logger(log_type).info('等待更新 URL 信息')
 | 
	
		
			
				|  |  | -                    time.sleep(10)
 | 
	
		
			
				|  |  | -                else:
 | 
	
		
			
				|  |  | -                    Common.logger(log_type).info('URL 信息已更新\n')
 | 
	
		
			
				|  |  | -                    break
 | 
	
		
			
				|  |  | +    @classmethod
 | 
	
		
			
				|  |  | +    def share_to_windows(cls, log_type, driver: WebDriver, video_dict, env):
 | 
	
		
			
				|  |  | +        # video_dict = cls.get_video_info(log_type, driver)
 | 
	
		
			
				|  |  | +        # if int(video_dict['duration']) < 50:
 | 
	
		
			
				|  |  | +        #     Common.logger(log_type).info(f'时长:{int(video_dict["duration"])} < 50 秒\n')
 | 
	
		
			
				|  |  | +        # elif video_dict['video_title'] == '':
 | 
	
		
			
				|  |  | +        #     Common.logger(log_type).info('视频标题为空\n')
 | 
	
		
			
				|  |  | +        # # 过滤词库(视频标题)
 | 
	
		
			
				|  |  | +        # elif any(word if word in video_dict['video_title'] else False for word in cls.filter_words(log_type)) is True:
 | 
	
		
			
				|  |  | +        #     Common.logger(log_type).info(f'视频已中过滤词:{video_dict["video_title"]}\n')
 | 
	
		
			
				|  |  | +        # # 视频号推荐_已下载表
 | 
	
		
			
				|  |  | +        # elif video_dict['video_title'] in [x for y in Feishu.get_values_batch(log_type, 'shipinhao', 'c77cf9') for x in y]:
 | 
	
		
			
				|  |  | +        #     Common.logger(log_type).info('视频已下载\n')
 | 
	
		
			
				|  |  | +        # # 视频号定向_已下载表
 | 
	
		
			
				|  |  | +        # elif video_dict['video_title'] in [x for y in Feishu.get_values_batch(log_type, 'shipinhao', 'XxmRlE') for x in y]:
 | 
	
		
			
				|  |  | +        #     Common.logger(log_type).info('视频已下载\n')
 | 
	
		
			
				|  |  | +        # # feeds 表去重
 | 
	
		
			
				|  |  | +        # elif video_dict['video_title'] in [x for y in Feishu.get_values_batch(log_type, 'shipinhao', 'FSDlBy') for x in y]:
 | 
	
		
			
				|  |  | +        #     Common.logger(log_type).info('视频已存在\n')
 | 
	
		
			
				|  |  | +        # # feeds 表去重
 | 
	
		
			
				|  |  | +        # elif video_dict['video_title'] in [x for y in Feishu.get_values_batch(log_type, 'shipinhao', 'qzDljJ') for x in y]:
 | 
	
		
			
				|  |  | +        #     Common.logger(log_type).info('视频已存在\n')
 | 
	
		
			
				|  |  | +        # # 分享给 windows 爬虫机
 | 
	
		
			
				|  |  | +        # else:
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        video_dict['share_id'].click()
 | 
	
		
			
				|  |  | +        driver.find_element(By.XPATH, '//*[@text="转发给朋友"]').click()
 | 
	
		
			
				|  |  | +        driver.find_element(By.XPATH, '//*[@text="爬虫群"]').click()
 | 
	
		
			
				|  |  | +        driver.find_element(By.ID, 'com.tencent.mm:id/guw').click()
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        # 把视频信息写入飞书feeds文档
 | 
	
		
			
				|  |  | +        Feishu.insert_columns(log_type, 'shipinhao', 'qzDljJ', 'ROWS', 1, 2)
 | 
	
		
			
				|  |  | +        get_feeds_time = int(time.time())
 | 
	
		
			
				|  |  | +        values = [[time.strftime('%Y/%m/%d %H:%M:%S', time.localtime(get_feeds_time)),
 | 
	
		
			
				|  |  | +                   '定向榜',
 | 
	
		
			
				|  |  | +                   str(video_dict['video_title']),
 | 
	
		
			
				|  |  | +                   int(video_dict['duration']),
 | 
	
		
			
				|  |  | +                   int(video_dict['like_cnt']),
 | 
	
		
			
				|  |  | +                   int(video_dict['share_cnt']),
 | 
	
		
			
				|  |  | +                   int(video_dict['favorite_cnt']),
 | 
	
		
			
				|  |  | +                   int(video_dict['comment_cnt']),
 | 
	
		
			
				|  |  | +                   str(video_dict['user_name'])]]
 | 
	
		
			
				|  |  | +        time.sleep(1)
 | 
	
		
			
				|  |  | +        Feishu.update_values(log_type, 'shipinhao', 'qzDljJ', 'A2:Z2', values)
 | 
	
		
			
				|  |  | +        Common.logger(log_type).info('视频信息写入飞书文档成功\n')
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        while True:
 | 
	
		
			
				|  |  | +            if Feishu.get_values_batch(log_type, 'shipinhao', 'qzDljJ')[1][11] is None:
 | 
	
		
			
				|  |  | +                Common.logger(log_type).info('等待更新 URL 信息')
 | 
	
		
			
				|  |  | +                time.sleep(10)
 | 
	
		
			
				|  |  | +            else:
 | 
	
		
			
				|  |  | +                Common.logger(log_type).info('URL 信息已更新\n')
 | 
	
		
			
				|  |  | +                break
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            cls.publish(log_type, env)
 | 
	
		
			
				|  |  | +        cls.download_publish(log_type, env)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      # 下载 、上传
 | 
	
		
			
				|  |  |      @classmethod
 | 
	
		
			
				|  |  | -    def publish(cls, log_type, env):
 | 
	
		
			
				|  |  | +    def download_publish(cls, log_type, env):
 | 
	
		
			
				|  |  |          try:
 | 
	
		
			
				|  |  |              follow_feeds_sheet = Feishu.get_values_batch(log_type, 'shipinhao', 'qzDljJ')
 | 
	
		
			
				|  |  |              for i in range(1, len(follow_feeds_sheet)):
 |