|
|
|
import argparse
|
|
|
|
import random
|
|
|
|
import time
|
|
|
|
import Contant
|
|
|
|
from LoggerUtils import Logger, initLogger
|
|
|
|
import Orm
|
|
|
|
from VideoService import VideoService
|
|
|
|
from ChannelService import ChannelService
|
|
|
|
from DownloadInfoService import DownloadService
|
|
|
|
from DownloadUtil import DownLoadUtil
|
|
|
|
from func_timeout import func_set_timeout
|
|
|
|
import func_timeout
|
|
|
|
import requests
|
|
|
|
|
|
|
|
# python3 ./main_download.py --db="../db/youtube_prod.db" --logDir="./logs"
|
|
|
|
if __name__ == "__main__":
|
|
|
|
parser = argparse.ArgumentParser(description='')
|
|
|
|
parser.add_argument('--db', type=str, default='')
|
|
|
|
parser.add_argument('--logDir', type=str, default='')
|
|
|
|
args = parser.parse_args()
|
|
|
|
Contant.db = args.db
|
|
|
|
Contant.logDir = args.logDir
|
|
|
|
initLogger()
|
|
|
|
Orm.ormInit()
|
|
|
|
testVideoId="oZhBWA3HNhA"
|
|
|
|
DownLoadUtil.downloadOne(testVideoId)
|
|
|
|
# list = DownloadService.findNotFinishList()
|
|
|
|
# Logger.info("list size:{}".format(len(list)))
|
|
|
|
# while (len(list) > 0):
|
|
|
|
# for info in list:
|
|
|
|
# try:
|
|
|
|
# DownLoadUtil.downloadOne(info.videoId)
|
|
|
|
# restTime = random.randint(1, 3)
|
|
|
|
# Logger.info("间隔{}秒后继续...".format(restTime))
|
|
|
|
# time.sleep(restTime)
|
|
|
|
# except func_timeout.exceptions.FunctionTimedOut as e:
|
|
|
|
# Logger.error("执行下载方法超时错误:{}".format(e))
|
|
|
|
# loopRestTime = random.randint(1, 3)
|
|
|
|
# Logger.info("循环间隔{}秒后继续...".format(loopRestTime))
|
|
|
|
# time.sleep(loopRestTime)
|
|
|
|
# list = DownloadService.findNotFinishList()
|
|
|
|
# # 发送钉钉消息
|
|
|
|
# webhook = "https://oapi.dingtalk.com/robot/send?access_token=c8c8d7d42c4eecd449dd303025ef968f647d1d8e8694e3fabc0ab5770d646dcb"
|
|
|
|
# jsonData = {
|
|
|
|
# "msgtype": "text",
|
|
|
|
# "text": {
|
|
|
|
# "content": "[Youtube]download finished"
|
|
|
|
# }
|
|
|
|
# }
|
|
|
|
# requests.post(webhook, json=jsonData)
|
|
|
|
# Logger.info("download发送钉钉消息成功...")
|