# -*- coding: utf-8 -*- # @Author: wangkun # @Time: 2022/4/25 import datetime import os import random import sys import time sys.path.append(os.getcwd()) from main.common import Common from main.download import BSZF class Main: @classmethod def download_job_dev(cls): """ 测试环境脚本 """ Common.crawler_log().info("开始抓取本山祝福视频\n") BSZF.get_recommend() BSZF.download_video("dev") # 删除多余日志 Common.del_logs() # 统计累计下载数量 Common.benshanzhufu_download_count() @classmethod def download_job_prod(cls): """ 正式环境脚本 """ while True: prod_time = datetime.datetime.now() if prod_time.hour < 9 or prod_time.hour > 12: Common.crawler_log().info("结束抓取视频\n") time.sleep(3) break else: BSZF.get_recommend() BSZF.download_video("dev") time.sleep(random.randint(1, 3)) # 删除多余日志 Common.del_logs() # 统计累计下载数量 Common.benshanzhufu_download_count() @classmethod def main(cls): while True: while True: main_time = datetime.datetime.now() if 12 >= main_time.hour >= 9: Common.crawler_log().info("开始抓取本山祝福视频\n") cls.download_job_prod() else: time.sleep(600) break if __name__ == "__main__": main = Main() main.main()