# -*- coding: utf-8 -*-
# @Author: wangkun
# @Time: 2023/7/26
import os
import sys
import time
sys.path.append(os.getcwd())
from common.common import Common
from shipinhao.shipinhao_recommend.recommend_h5 import RecommendH5
from shipinhao.shipinhao_recommend.shipinhao_recommend import ShipinhaoRecommend


class ShipinhaoRecommendMain:
    @classmethod
    def shipinhao_recommend_main(cls, log_type, crawler, env):
        while True:
            Common.logger(log_type, crawler).info("开始抓取视频号推荐\n")
            Common.logging(log_type, crawler, env, "开始抓取视频号推荐\n")
            scan_count = 20
            rule_dict = {"period": {"min": 365, "max": 365},
                         "duration": {"min": 10, "max": 1800},
                         "favorite_cnt": {"min": 5000, "max": 0},
                         "share_cnt": {"min": 1000, "max": 0}}
            ShipinhaoRecommend.get_recommend_list(log_type=log_type,
                                                  crawler=crawler,
                                                  rule_dict=rule_dict,
                                                  scan_count = scan_count,
                                                  env=env)
            RecommendH5.download_videos(log_type=log_type,
                                        crawler=crawler,
                                        env=env,
                                        rule_dict=rule_dict,
                                        our_uid="6267140")
            Common.logger(log_type, crawler).info("抓取一轮结束\n")
            Common.logging(log_type, crawler, env, "抓取一轮结束\n")
            ShipinhaoRecommend.download_video_list = []
            time.sleep(5)


if __name__ == "__main__":
    ShipinhaoRecommendMain.shipinhao_recommend_main("recommend", "shipinhao", "prod")
