add 优化代码,新增获取腾讯视频播放列表

This commit is contained in:
SummerTail 2023-07-03 12:04:52 +08:00
parent 0c010beb54
commit b48ccbf84d
5 changed files with 45 additions and 26 deletions

Binary file not shown.

View File

@ -18,6 +18,7 @@
"koa-sse-stream": "^0.2.0",
"koa-static": "^5.0.0",
"koa-websocket": "^7.0.0",
"process": "^0.11.10",
"puppeteer": "^20.7.1",
"sqlite3": "^5.1.6"
},

View File

@ -4,10 +4,9 @@ const utils = require("../util/utils")
const KoaSSEStream = require('koa-sse-stream');
const {dowload} = require("../util/download");
const {addDownList, getDownList, setDownState} = require("../util/sql/download");
const dayjs = require("dayjs")
const {getMediaInfo} = require("../util/utils");
const router = new Router()
// const dowloadlist = []
// const download = []
router.get("/getMediaInfo", async (ctx) => {
let url = ctx.query.filePath
@ -26,22 +25,21 @@ router.get("/getMediaInfo", async (ctx) => {
router.get("/getQqList", async (ctx) => {
let url = ctx.query.url
let videoid = url.split("/")
for (let i in videoid) {
if (videoid[i] == "cover") {
videoid = videoid[i + 1].replace(".html")
let video_id = url.split("/")
for (let i in video_id) {
if (video_id[i] === "cover") {
video_id = video_id[i + 1].replace(".html")
break
}
}
let list = await getQqListData(url)
ctx.body = list
ctx.body = await getQqListData(url)
})
router.get("/startDown", async (ctx) => {
let title = ctx.query.title
let url = ctx.query.url
let save = ctx.query.save
// dowloadlist.push({
// download.push({
// title,url,save
// })
// startDown()
@ -53,7 +51,12 @@ router.get("/startDown", async (ctx) => {
})
router.get("/test", async (ctx) => {
utils.getVideoSpecifyTimeImage("D:/aaa/梦中的那片海/梦中的那片海 第01集.mp4", 46, "D:/aaa/梦中的那片海/aaa.jpg")
let rep = await utils.getTencentVideoPlayList('mzc00200t7i1qwp')
ctx.body = {
code: 0,
msg: "test",
data: rep
}
})
@ -92,9 +95,9 @@ function startDown(data) {
setInterval(async () => {
let dowloadlist = await getDownList()
if (dowloadlist.length != 0 && !start) {
if (dowloadlist.length !== 0 && !start) {
startDown(dowloadlist[0])
} else if (dowloadlist.length == 0) {
} else if (dowloadlist.length === 0) {
start = false
}
}, 1000)

View File

@ -22,7 +22,7 @@ async function getQqListData(url) {
console.log(list)
for (let i of list) {
if (i && i.innerText) {
if ("全部" == i.innerText.trim()) {
if ("全部" === i.innerText.trim()) {
i.click()
}
}

View File

@ -11,12 +11,26 @@ function seep(time) {
})
}
/**
* 获取腾讯视频播放列表
* @param {String}cid 视频id
* @returns {JSON} 播放列表等参数
*/
function getTencentVideoPlayList(cid) {
return new Promise((resolve) => {
const lux = spawn("./bin/getTencentVideoPlayList.exe", [cid, 'vversion_name=8.2.95;', 1])
lux.stdout.on('data', (data) => {
resolve(JSON.parse(String(data)))
});
})
}
/**
* 获取视频截图 (目前不可用,不好使)
* 获取视频截图
* @param {String} filePath 文件绝对路径
* @param {number} seconds 时间
* @param {Promise<String>} save 保存绝对路径(含文件名)
* @param {string} save 保存绝对路径(含文件名)
* @returns {Promise<String>} 文件位置(待定)
*/
function getVideoSpecifyTimeImage(filePath, seconds, save) {
@ -68,7 +82,7 @@ function createTorrent(filePath, save) {
lux.stdout.on('data', (data) => {
response += data
});
lux.stdout.on('close', (code) => {
lux.stdout.on('close', () => {
resolve(response)
})
})
@ -133,5 +147,6 @@ module.exports = {
dow,
getVideoSpecifyTimeImage,
getMediaInfo,
createTorrent
createTorrent,
getTencentVideoPlayList
}