# -*- coding: utf-8 -*-
# @Author: wangkun
# @Time: 2023/8/22
import datetime
import os
import sys
sys.path.append(os.getcwd())
from common.common import Common
from zhiqingtiantiankan.zhiqingtiantiankan_recommend.zhiqingtiantiankan_recommend import ZhiqingtiantiankanRecommend
from ganggangdouchuan.ganggangdouchuan_recommend.ganggangdouchuan_recommend import GanggangdouchuanRecommend
from jixiangxingfu.jixiangxingfu_recommend.jixiangxingfu_recommend import JixiangxingfuRecommend
from zhongmiaoyinxin.zhongmiaoyinxin_recommend.zhongmiaoyinxin_recommend import ZhongmiaoyinxinRecommend


def offline_main():
    while True:
        if 0 <= datetime.datetime.now().hour <= 8:
            Common.logger("recommend", "zhiqingtiantiankan").info('开始抓取:知青天天看小程序\n')
            ZhiqingtiantiankanRecommend.start_wechat("recommend", "zhiqingtiantiankan", "prod")
            Common.del_logs("recommend", "zhiqingtiantiankan")
            Common.logger("recommend", "zhiqingtiantiankan").info('抓取完一轮\n')
        elif 9 <= datetime.datetime.now().hour <= 12:
            oss_endpoint = "inner"
            Common.logger("recommend", "ganggangdouchuan").info('开始抓取:刚刚都传小程序\n')
            GanggangdouchuanRecommend.start_wechat("recommend", "ganggangdouchuan", oss_endpoint, "prod")
            Common.del_logs("recommend", "ganggangdouchuan")
            Common.logger("recommend", "ganggangdouchuan").info('抓取完一轮\n')
        elif 13 <= datetime.datetime.now().hour <= 16:
            Common.logger("recommend", "jixiangxingfu").info('开始抓取:吉祥幸福小程序\n')
            JixiangxingfuRecommend.start_wechat("recommend", "jixiangxingfu", "prod")
            Common.del_logs("recommend", "jixiangxingfu")
            Common.logger("recommend", "jixiangxingfu").info('抓取完一轮\n')
        elif 17 <= datetime.datetime.now().hour <= 23:
            Common.logger("recommend", "zhongmiaoyinxin").info('开始抓取:众妙音信小程序\n')
            ZhongmiaoyinxinRecommend.start_wechat("recommend", "zhongmiaoyinxin", "prod")
            Common.del_logs("recommend", "zhongmiaoyinxin")
            Common.logger("recommend", "zhongmiaoyinxin").info('抓取完一轮\n')


if __name__ == "__main__":
    offline_main()