1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- # -*- coding: utf-8 -*-
- # @Author: wangkun
- # @Time: 2022/4/25
- import datetime
- import os
- 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):
- """
- 测试环境脚本
- """
- if len(BSZF.download_video_list) >= 10:
- Common.crawler_log().info("已下载视频数:{}".format(len(BSZF.download_video_list)))
- time.sleep(1800)
- else:
- Common.crawler_log().info("开始抓取本山祝福视频\n")
- BSZF.get_recommend()
- BSZF.download_video("dev")
- # 删除多余日志
- Common.del_logs()
- # 统计累计下载数量
- Common.benshanzhufu_download_count()
- @classmethod
- def main_dev(cls):
- while True:
- while True:
- main_dev_time = datetime.datetime.now()
- if main_dev_time.hour >= 15:
- cls.download_job_dev()
- else:
- break
- @classmethod
- def download_job_prod(cls):
- """
- 正式环境脚本
- """
- if len(BSZF.download_video_list) >= 200:
- Common.crawler_log().info("已下载视频数:{}".format(len(BSZF.download_video_list)))
- time.sleep(1800)
- else:
- Common.crawler_log().info("开始抓取本山祝福视频\n")
- BSZF.get_recommend()
- BSZF.download_video("prod")
- # 删除多余日志
- Common.del_logs()
- # 统计累计下载数量
- Common.benshanzhufu_download_count()
- @classmethod
- def main(cls):
- while True:
- while True:
- main_time = datetime.datetime.now()
- if main_time.hour >= 11:
- cls.download_job_prod()
- else:
- break
- if __name__ == "__main__":
- main = Main()
- main.main()
- # main.main_dev()
|