run_shipinhao_recommend.py 962 B

1234567891011121314151617181920212223242526272829303132
  1. # -*- coding: utf-8 -*-
  2. # @Author: wangkun
  3. # @Time: 2022/8/31
  4. import datetime
  5. import os
  6. import sys
  7. import time
  8. sys.path.append(os.getcwd())
  9. from main.common import Common
  10. from main.shipinhao_recommend import Recommend
  11. class Main:
  12. @classmethod
  13. def main(cls, env):
  14. while True:
  15. if 20 >= datetime.datetime.now().hour >= 10:
  16. if len(Recommend.download_cnt) >= 100:
  17. Recommend.download_cnt = []
  18. Common.del_logs('recommend')
  19. Common.logger('recommend').info(
  20. '已下载{}条视频,休眠{}小时', len(Recommend.download_cnt), 24-datetime.datetime.now().hour)
  21. time.sleep(3600 * (24-datetime.datetime.now().hour))
  22. else:
  23. Recommend.start_wechat('recommend', env)
  24. time.sleep(3)
  25. else:
  26. pass
  27. if __name__ == '__main__':
  28. Main.main('prod')