add 订阅自动检查更新
This commit is contained in:
parent
573883e2d1
commit
be48d26d8c
BIN
db/database.db
BIN
db/database.db
Binary file not shown.
3
index.js
3
index.js
@ -23,4 +23,7 @@ const videoInfo = require("./router/videoInfo.js");
|
||||
|
||||
app.use(videoInfo.routes()).use(videoInfo.allowedMethods())
|
||||
app.listen(3050, "0.0.0.0");
|
||||
|
||||
// 引入定时检测更新
|
||||
require("./util/Video/Update.js")
|
||||
console.log("link: http://127.0.0.1:3050")
|
@ -19,6 +19,7 @@
|
||||
"koa-sse-stream": "^0.2.0",
|
||||
"koa-static": "^5.0.0",
|
||||
"koa-websocket": "^7.0.0",
|
||||
"node-schedule": "^2.1.1",
|
||||
"process": "^0.11.10",
|
||||
"puppeteer": "^20.7.1",
|
||||
"sqlite3": "^5.1.6"
|
||||
|
@ -28,6 +28,9 @@ dependencies:
|
||||
koa-websocket:
|
||||
specifier: ^7.0.0
|
||||
version: 7.0.0
|
||||
node-schedule:
|
||||
specifier: ^2.1.1
|
||||
version: 2.1.1
|
||||
process:
|
||||
specifier: ^0.11.10
|
||||
version: 0.11.10
|
||||
@ -642,6 +645,13 @@ packages:
|
||||
path-type: 4.0.0
|
||||
dev: false
|
||||
|
||||
/cron-parser@4.8.1:
|
||||
resolution: {integrity: sha512-jbokKWGcyU4gl6jAfX97E1gDpY12DJ1cLJZmoDzaAln/shZ+S3KBFBuA2Q6WeUN4gJf/8klnV1EfvhA2lK5IRQ==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
dependencies:
|
||||
luxon: 3.3.0
|
||||
dev: false
|
||||
|
||||
/cross-fetch@3.1.6:
|
||||
resolution: {integrity: sha512-riRvo06crlE8HiqOwIpQhxwdOk4fOeR7FVM/wXoxchFEqMNUjvbs3bfo4OTgMEMHzppd4DxFBDbyySj8Cv781g==}
|
||||
dependencies:
|
||||
@ -1424,6 +1434,10 @@ packages:
|
||||
resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==}
|
||||
dev: false
|
||||
|
||||
/long-timeout@0.1.1:
|
||||
resolution: {integrity: sha512-BFRuQUqc7x2NWxfJBCyUrN8iYUYznzL9JROmRz1gZ6KlOIgmoD+njPVbb+VNn2nGMKggMsK79iUNErillsrx7w==}
|
||||
dev: false
|
||||
|
||||
/lru-cache@6.0.0:
|
||||
resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==}
|
||||
engines: {node: '>=10'}
|
||||
@ -1436,6 +1450,11 @@ packages:
|
||||
engines: {node: '>=12'}
|
||||
dev: false
|
||||
|
||||
/luxon@3.3.0:
|
||||
resolution: {integrity: sha512-An0UCfG/rSiqtAIiBPO0Y9/zAnHUZxAMiCpTd5h2smgsj7GGmcenvrvww2cqNA8/4A5ZrD1gJpHN2mIHZQF+Mg==}
|
||||
engines: {node: '>=12'}
|
||||
dev: false
|
||||
|
||||
/make-dir@3.1.0:
|
||||
resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==}
|
||||
engines: {node: '>=8'}
|
||||
@ -1627,6 +1646,15 @@ packages:
|
||||
dev: false
|
||||
optional: true
|
||||
|
||||
/node-schedule@2.1.1:
|
||||
resolution: {integrity: sha512-OXdegQq03OmXEjt2hZP33W2YPs/E5BcFQks46+G2gAxs4gHOIVD1u7EqlYLYSKsaIpyKCK9Gbk0ta1/gjRSMRQ==}
|
||||
engines: {node: '>=6'}
|
||||
dependencies:
|
||||
cron-parser: 4.8.1
|
||||
long-timeout: 0.1.1
|
||||
sorted-array-functions: 1.3.0
|
||||
dev: false
|
||||
|
||||
/nopt@5.0.0:
|
||||
resolution: {integrity: sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==}
|
||||
engines: {node: '>=6'}
|
||||
@ -2021,6 +2049,10 @@ packages:
|
||||
smart-buffer: 4.2.0
|
||||
dev: false
|
||||
|
||||
/sorted-array-functions@1.3.0:
|
||||
resolution: {integrity: sha512-2sqgzeFlid6N4Z2fUQ1cvFmTOLRi/sEDzSQ0OKYchqgoPmQBVyM3959qYx3fpS6Esef80KjmpgPeEr028dP3OA==}
|
||||
dev: false
|
||||
|
||||
/source-map@0.6.1:
|
||||
resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
@ -95,28 +95,28 @@ router.get('/msg', KoaSSEStream(SSE_CONF), ctx => {
|
||||
}
|
||||
})
|
||||
let start = false
|
||||
|
||||
function startDown(data) {
|
||||
start = true
|
||||
dowload(data, async (data2, isok) => {
|
||||
let name = data2.title
|
||||
clientList.forEach((i) => {
|
||||
i.send(isok ? `${name}下载完成` : data2)
|
||||
})
|
||||
if (isok) {
|
||||
// dowloadlist.shift()
|
||||
await setDownState(data.id, 1)
|
||||
start = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
setInterval(async () => {
|
||||
let dowloadlist = await getDownList()
|
||||
if (dowloadlist.length !== 0 && !start) {
|
||||
startDown(dowloadlist[0])
|
||||
} else if (dowloadlist.length === 0) {
|
||||
start = false
|
||||
}
|
||||
}, 1000)
|
||||
// 下载检测
|
||||
// function startDown(data) {
|
||||
// start = true
|
||||
// dowload(data, async (data2, isok) => {
|
||||
// let name = data2.title
|
||||
// clientList.forEach((i) => {
|
||||
// i.send(isok ? `${name}下载完成` : data2)
|
||||
// })
|
||||
// if (isok) {
|
||||
// // dowloadlist.shift()
|
||||
// await setDownState(data.id, 1)
|
||||
// start = false
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// 定时检测下载地址
|
||||
// setInterval(async () => {
|
||||
// let dowloadlist = await getDownList()
|
||||
// if (dowloadlist.length !== 0 && !start) {
|
||||
// startDown(dowloadlist[0])
|
||||
// } else if (dowloadlist.length === 0) {
|
||||
// start = false
|
||||
// }
|
||||
// }, 1000)
|
||||
module.exports = router
|
38
util/Video/Update.js
Normal file
38
util/Video/Update.js
Normal file
@ -0,0 +1,38 @@
|
||||
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")
|
||||
let list = await getQqListData(cid)
|
||||
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`, `d:/aaa/${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()
|
||||
});
|
@ -1,7 +1,7 @@
|
||||
const puppeteer = require("puppeteer")
|
||||
const { seep } = require("../utils.js");
|
||||
|
||||
async function getQqListData(url) {
|
||||
const { seep, spawn } = require("../utils.js");
|
||||
// 无头浏览器模式 暂时禁用
|
||||
async function getQqListDataBack(url) {
|
||||
const browser = await puppeteer.launch({
|
||||
// 关闭无头模式,方便我们看到这个无头浏览器执行的过程
|
||||
headless: false,
|
||||
@ -85,6 +85,24 @@ async function getQqListData(url) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
function getQqListData(cid){
|
||||
return new Promise((resolve) => {
|
||||
const lux = spawn("getTencentVideoPlayList", [cid, 'vversion_name=8.2.95;', 1])
|
||||
lux.stdout.on('data', (data) => {
|
||||
resolve(JSON.parse(String(data)))
|
||||
});
|
||||
lux.stderr.on("data",(a)=>{
|
||||
console.log(a)
|
||||
})
|
||||
lux.stdout.on("error",(err)=>{
|
||||
console.log(err)
|
||||
})
|
||||
lux.stderr.on("error",(err)=>{
|
||||
console.log(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
module.exports = {
|
||||
getQqListData
|
||||
}
|
@ -1,8 +1,9 @@
|
||||
const { run, getAll } = require("./base");
|
||||
|
||||
function addDownList(title,url,save,downDate,isOk,vid){
|
||||
let sql = `insert into download(title,url,save,downDate,isOk,vid) values(?,?,?,?,?,?)`
|
||||
run(sql,title,url,save,downDate,isOk,vid)
|
||||
// state 0未下载 1下载完成 2已发种
|
||||
function addDownList(title,url,save,downDate,state,vid){
|
||||
let sql = `insert into download(title,url,save,downDate,state,vid) values(?,?,?,?,?,?)`
|
||||
run(sql,title,url,save,downDate,state,vid)
|
||||
}
|
||||
|
||||
async function getDownList(){
|
||||
|
@ -12,20 +12,29 @@ async function addSub(info){
|
||||
await run(sql,info.name,info.rename,info.skip,info.desc,info.url,info.subtitle,info.img,info.year,info.time,info.season,info.sid,info.count)
|
||||
}
|
||||
|
||||
// 获取所有订阅 (不包括已完成)
|
||||
async function getSub(){
|
||||
let sql = `select * from VideoInfo`
|
||||
let sql = `select * from VideoInfo where enable=1`
|
||||
let list = await getAll(sql)
|
||||
return list
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function delSub(id){
|
||||
let sql = `delete from VideoInfo where id=${id}`
|
||||
await run(sql)
|
||||
}
|
||||
|
||||
async function updateSkip(num,id){
|
||||
let sql = `update VideoInfo set skip=${num} where id=${id}`
|
||||
await run(sql)
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
addSub,
|
||||
getSub,
|
||||
delSub
|
||||
delSub,
|
||||
updateSkip
|
||||
}
|
@ -1,10 +1,22 @@
|
||||
const { spawn } = require('child_process');
|
||||
const { spawn: spawn2 } = require('child_process');
|
||||
const path = require('path');
|
||||
const { cwd } = require('process');
|
||||
const { readFile, createReadStream } = require("fs");
|
||||
const { post } = require("axios");
|
||||
const https = require('https')
|
||||
|
||||
// 设置环境变量为自带的bin
|
||||
function spawn(exe, arg, config) {
|
||||
if (!config) {
|
||||
config = {}
|
||||
}
|
||||
config.env = {
|
||||
path: [path.join(cwd(), '/bin'), path.join(cwd(), '/bin/MediaInfoCLI'), path.join(cwd(), '/bin/Transmission')].join(";")
|
||||
}
|
||||
|
||||
return spawn2(exe, arg, config)
|
||||
}
|
||||
|
||||
function seep(time) {
|
||||
return new Promise((res) => {
|
||||
setTimeout(() => {
|
||||
@ -45,7 +57,7 @@ async function uploadImg(filePath) {
|
||||
*/
|
||||
function getTencentVideoPlayList(cid) {
|
||||
return new Promise((resolve) => {
|
||||
const lux = spawn("./bin/getTencentVideoPlayList.exe", [cid, 'vversion_name=8.2.95;', 1])
|
||||
const lux = spawn("getTencentVideoPlayList.exe", [cid, 'vversion_name=8.2.95;', 1])
|
||||
lux.stdout.on('data', (data) => {
|
||||
resolve(JSON.parse(String(data)))
|
||||
});
|
||||
@ -89,7 +101,7 @@ function getVideoSpecifyTimeImage(filePath, seconds, save) {
|
||||
*/
|
||||
function getMediaInfo(filePath) {
|
||||
return new Promise((resolve) => {
|
||||
const lux = spawn("./bin/MediaInfoCLI/MediaInfo.exe", ['--output=JSON', filePath])
|
||||
const lux = spawn("MediaInfo.exe", ['--output=JSON', filePath])
|
||||
lux.stdout.on('data', (data) => {
|
||||
resolve(JSON.parse(data))
|
||||
});
|
||||
@ -104,7 +116,7 @@ function getMediaInfo(filePath) {
|
||||
*/
|
||||
function createTorrent(filePath, save) {
|
||||
return new Promise((resolve) => {
|
||||
const lux = spawn("./bin/Transmission/transmission-create", [filePath, '-p', '-t https://zmpt.cc/announce.php', '-o', save])
|
||||
const lux = spawn("transmission-create", [filePath, '-p', '-t https://zmpt.cc/announce.php', '-o', save])
|
||||
let response = '';
|
||||
lux.stdout.on('data', (data) => {
|
||||
response += data
|
||||
@ -176,5 +188,6 @@ module.exports = {
|
||||
getMediaInfo,
|
||||
createTorrent,
|
||||
getTencentVideoPlayList,
|
||||
uploadImg
|
||||
uploadImg,
|
||||
spawn
|
||||
}
|
@ -12,6 +12,7 @@
|
||||
"@element-plus/icons-vue": "^2.1.0",
|
||||
"axios": "^1.4.0",
|
||||
"element-plus": "^2.3.6",
|
||||
"node-schedule": "^2.1.1",
|
||||
"sass": "^1.63.3",
|
||||
"vue": "^3.2.47",
|
||||
"vue-router": "4"
|
||||
|
@ -1,9 +1,5 @@
|
||||
lockfileVersion: '6.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
dependencies:
|
||||
'@element-plus/icons-vue':
|
||||
specifier: ^2.1.0
|
||||
@ -14,6 +10,9 @@ dependencies:
|
||||
element-plus:
|
||||
specifier: ^2.3.6
|
||||
version: 2.3.6(vue@3.2.47)
|
||||
node-schedule:
|
||||
specifier: ^2.1.1
|
||||
version: 2.1.1
|
||||
sass:
|
||||
specifier: ^1.63.3
|
||||
version: 1.63.3
|
||||
@ -465,6 +464,13 @@ packages:
|
||||
delayed-stream: 1.0.0
|
||||
dev: false
|
||||
|
||||
/cron-parser@4.8.1:
|
||||
resolution: {integrity: sha512-jbokKWGcyU4gl6jAfX97E1gDpY12DJ1cLJZmoDzaAln/shZ+S3KBFBuA2Q6WeUN4gJf/8klnV1EfvhA2lK5IRQ==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
dependencies:
|
||||
luxon: 3.3.0
|
||||
dev: false
|
||||
|
||||
/csstype@2.6.21:
|
||||
resolution: {integrity: sha512-Z1PhmomIfypOpoMjRQB70jfvy/wxT50qW08YXO5lMIJkrdq4yOTR+AW7FqutScmB9NkLwxo+jU+kZLbofZZq/w==}
|
||||
|
||||
@ -620,6 +626,15 @@ packages:
|
||||
resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==}
|
||||
dev: false
|
||||
|
||||
/long-timeout@0.1.1:
|
||||
resolution: {integrity: sha512-BFRuQUqc7x2NWxfJBCyUrN8iYUYznzL9JROmRz1gZ6KlOIgmoD+njPVbb+VNn2nGMKggMsK79iUNErillsrx7w==}
|
||||
dev: false
|
||||
|
||||
/luxon@3.3.0:
|
||||
resolution: {integrity: sha512-An0UCfG/rSiqtAIiBPO0Y9/zAnHUZxAMiCpTd5h2smgsj7GGmcenvrvww2cqNA8/4A5ZrD1gJpHN2mIHZQF+Mg==}
|
||||
engines: {node: '>=12'}
|
||||
dev: false
|
||||
|
||||
/magic-string@0.25.9:
|
||||
resolution: {integrity: sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==}
|
||||
dependencies:
|
||||
@ -646,6 +661,15 @@ packages:
|
||||
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
|
||||
hasBin: true
|
||||
|
||||
/node-schedule@2.1.1:
|
||||
resolution: {integrity: sha512-OXdegQq03OmXEjt2hZP33W2YPs/E5BcFQks46+G2gAxs4gHOIVD1u7EqlYLYSKsaIpyKCK9Gbk0ta1/gjRSMRQ==}
|
||||
engines: {node: '>=6'}
|
||||
dependencies:
|
||||
cron-parser: 4.8.1
|
||||
long-timeout: 0.1.1
|
||||
sorted-array-functions: 1.3.0
|
||||
dev: false
|
||||
|
||||
/normalize-path@3.0.0:
|
||||
resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
@ -696,6 +720,10 @@ packages:
|
||||
immutable: 4.3.0
|
||||
source-map-js: 1.0.2
|
||||
|
||||
/sorted-array-functions@1.3.0:
|
||||
resolution: {integrity: sha512-2sqgzeFlid6N4Z2fUQ1cvFmTOLRi/sEDzSQ0OKYchqgoPmQBVyM3959qYx3fpS6Esef80KjmpgPeEr028dP3OA==}
|
||||
dev: false
|
||||
|
||||
/source-map-js@1.0.2:
|
||||
resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
@ -783,3 +811,7 @@ packages:
|
||||
'@vue/runtime-dom': 3.2.47
|
||||
'@vue/server-renderer': 3.2.47(vue@3.2.47)
|
||||
'@vue/shared': 3.2.47
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
Loading…
Reference in New Issue
Block a user