const schedule = require('node-schedule'); const { getSub,updateSkip } = require('../sql/video'); const { getQqListData } = require("../getList/qq.js") const { addDownList } = require("../sql/download.js") // 检查更新并将更新推送下载 async function addDown(i) { // 判断视频网站 if (i.url.indexOf("v.qq.com") != -1) { let cid = i.url.split("/")[5].replace(".html","") console.log(cid) let list = await getQqListData(cid) console.log(list) list = list.item_datas for (let j = i.skip - 1; j < list.length; j++) { let v = list[j] await addDownList(v.item_params.title, `https://v.qq.com/x/cover/${cid}/${v.item_params.vid}.html`, `k:/dltest/${i.sid}`, new Date().getTime(), 0, i.sid) } await updateSkip(list.length + 1,i.id) // console.log(JSON.stringify(list)) } } async function CheckUpdate() { let date = new Date() let hours = date.getHours() let minutes = date.getMinutes() let all = await getSub() for (let i of all) { let time = i.time.split(":") if (hours == time[0] && minutes == time[1]) { addDown(i) } } } console.log("开始定时检测更新") // 设置定时器 每分钟检测更新 let job = schedule.scheduleJob('0 * * * * *', () => { CheckUpdate() });