diff --git a/bin/getTencentVideoPlayList.exe b/bin/getTencentVideoPlayList.exe new file mode 100644 index 0000000..8044e75 Binary files /dev/null and b/bin/getTencentVideoPlayList.exe differ diff --git a/package.json b/package.json index 2982dca..0624039 100644 --- a/package.json +++ b/package.json @@ -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" }, @@ -41,4 +42,4 @@ "output": "./dist" } } -} \ No newline at end of file +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d623100..ec72105 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,5 +1,9 @@ lockfileVersion: '6.0' +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + dependencies: axios: specifier: ^1.4.0 @@ -25,6 +29,9 @@ dependencies: koa-websocket: specifier: ^7.0.0 version: 7.0.0 + process: + specifier: ^0.11.10 + version: 0.11.10 puppeteer: specifier: ^20.7.1 version: 20.7.1 @@ -1680,6 +1687,11 @@ packages: engines: {node: '>= 0.8.0'} dev: false + /process@0.11.10: + resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==} + engines: {node: '>= 0.6.0'} + dev: false + /progress@2.0.3: resolution: {integrity: sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==} engines: {node: '>=0.4.0'} diff --git a/router/index.js b/router/index.js index cec018c..4ef5efe 100644 --- a/router/index.js +++ b/router/index.js @@ -4,10 +4,21 @@ 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("/test", async (ctx) => { + await utils.uploadImg('C:\\Users\\SummerTail\\Pictures\\Snipaste_2023-07-03_22-16-37.png') + ctx.body = { + code: 0, + msg: "test", + data: '' + } +}) + + router.get("/getMediaInfo", async (ctx) => { let url = ctx.query.filePath @@ -26,22 +37,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() @@ -52,9 +62,6 @@ router.get("/startDown", async (ctx) => { } }) -router.get("/test", async (ctx) => { - utils.getVideoSpecifyTimeImage("D:/aaa/梦中的那片海/梦中的那片海 第01集.mp4", 46, "D:/aaa/梦中的那片海/aaa.jpg") -}) // 连接池 @@ -92,9 +99,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) diff --git a/util/getList/qq.js b/util/getList/qq.js index 9f6809e..5bc4487 100644 --- a/util/getList/qq.js +++ b/util/getList/qq.js @@ -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() } } diff --git a/util/utils.js b/util/utils.js index d4451ba..8027ecf 100644 --- a/util/utils.js +++ b/util/utils.js @@ -1,7 +1,8 @@ const {spawn} = require('child_process'); const path = require('path'); -const { cwd } = require('process'); - +const {cwd} = require('process'); +const {readFile} = require("fs"); +const {post} = require("axios"); function seep(time) { return new Promise((res) => { @@ -11,19 +12,50 @@ function seep(time) { }) } +/** + * 上传图片至图床 (暂不可用) + * @param filePath 图片路径 + */ +function uploadImg(filePath) { + + readFile(filePath, function (err, data) { + let formData = new FormData() + formData.append('file', data) + post('https://image.zmpt.cc/upload/localhost', formData).then((response, headers) => { + console.info(response) + }) + }) + +} + /** - * 获取视频截图 (目前不可用,不好使) + * 获取腾讯视频播放列表 + * @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} save 保存绝对路径(含文件名) + * @param {string} save 保存绝对路径(含文件名) * @returns {Promise} 文件位置(待定) */ function getVideoSpecifyTimeImage(filePath, seconds, save) { return new Promise((resolve) => { - const lux = spawn("ffmpeg", ['-ss',`${formatSeconds(seconds)}`,'-i',filePath,'-vframes','1',save],{ - env:{ - path:path.join(cwd(),'./bin/') + const lux = spawn("ffmpeg", ['-ss', `${formatSeconds(seconds)}`, '-i', filePath, '-vframes', '1', save], { + env: { + path: path.join(cwd(), './bin/') } }) lux.stdout.on('data', (data) => { @@ -34,7 +66,7 @@ function getVideoSpecifyTimeImage(filePath, seconds, save) { console.log(code.toString()) resolve(save) }); - lux.stderr.on("data",(err)=>{ + lux.stderr.on("data", (err) => { console.log(String(err)) }) console.log(lux) @@ -68,7 +100,7 @@ function createTorrent(filePath, save) { lux.stdout.on('data', (data) => { response += data }); - lux.stdout.on('close', (code) => { + lux.stdout.on('close', () => { resolve(response) }) }) @@ -76,9 +108,9 @@ function createTorrent(filePath, save) { function dow(info, callback) { - const lux = spawn("yt-dlp", ['--cookies-from-browser', 'chrome', '-P', info.save, '-o', info.title + '.mp4', info.url],{ - env:{ - path:path.join(cwd(),'./bin/') + const lux = spawn("yt-dlp", ['--cookies-from-browser', 'chrome', '-P', info.save, '-o', info.title + '.mp4', info.url], { + env: { + path: path.join(cwd(), './bin/') } }) lux.stdout.on('data', (data) => { @@ -133,5 +165,7 @@ module.exports = { dow, getVideoSpecifyTimeImage, getMediaInfo, - createTorrent + createTorrent, + getTencentVideoPlayList, + uploadImg } \ No newline at end of file diff --git a/view/README.md b/view/README.md index e62e093..1bb8a7b 100644 --- a/view/README.md +++ b/view/README.md @@ -1,7 +1,14 @@ -# Vue 3 + Vite +# WEB-DL全自动发布工具 -This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 ` - + +
diff --git a/view/src/menu/leftMenu.vue b/view/src/menu/leftMenu.vue index f2537c8..e1d6b24 100644 --- a/view/src/menu/leftMenu.vue +++ b/view/src/menu/leftMenu.vue @@ -1,37 +1,92 @@ diff --git a/view/src/page/subscribe/subscribe.vue b/view/src/page/subscribe/subscribe.vue new file mode 100644 index 0000000..297369f --- /dev/null +++ b/view/src/page/subscribe/subscribe.vue @@ -0,0 +1,52 @@ + + + + + diff --git a/view/src/page/test/downloadTest.vue b/view/src/page/test/downloadTest.vue index 1a870c3..64f70f2 100644 --- a/view/src/page/test/downloadTest.vue +++ b/view/src/page/test/downloadTest.vue @@ -17,7 +17,6 @@
设置 - 测试按钮
@@ -137,14 +136,6 @@ function showMsg() { dialogVisible.value = true } -function test() { - axios.get("/test", { - params: {url: form.value.name} - }).then((r) => { - console.log(r.data); - }) -} -