"""
@author: luojunhui
"""
import datetime
import time

import schedule

from tasks import *


# 自动迁移数据任务
def migrate_videos_task():
    """
    自动迁移数据
    :return:
    """
    today = datetime.datetime.today()
    yesterday = today - datetime.timedelta(days=1)
    dt = yesterday.strftime("%Y%m%d")
    migrate_daily(dt=dt)


# 自动下架视频任务
def get_off_videos_task():
    """
    自动下架视频
    :return:
    """
    AG = AutoGetOffVideos()
    AG.task1()


if __name__ == '__main__':
    schedule.every().day.at("01:00").do(source_id_job)

    schedule.every().day.at("05:00").do(migrate_videos_task)

    schedule.every().day.at("11:00").do(get_off_videos_task)

    schedule.every().day.at("15:00").do(get_off_videos_task)

    while True:
        schedule.run_pending()
        print("定时任务正在执行\t{}".format(datetime.datetime.now().__str__()))
        time.sleep(1)
