init
This commit is contained in:
63
util/getList/qq.js
Normal file
63
util/getList/qq.js
Normal file
@@ -0,0 +1,63 @@
|
||||
const puppeteer = require("puppeteer")
|
||||
const { seep } = require("../utils.js");
|
||||
|
||||
async function getListData(url) {
|
||||
const browser = await puppeteer.launch({
|
||||
// 关闭无头模式,方便我们看到这个无头浏览器执行的过程
|
||||
headless: false,
|
||||
timeout: 0 // 默认超时为30秒,设置为0则表示不设置超时
|
||||
});
|
||||
const page = await browser.newPage();
|
||||
page.setViewport({
|
||||
width: 1376,
|
||||
height: 768,
|
||||
});
|
||||
await page.goto(url, {});
|
||||
let list = await page.evaluate(() => {
|
||||
return window.__PINIA__.episodeMain
|
||||
})
|
||||
for (let i of list.listData[0].tabs) {
|
||||
let text = i.text
|
||||
let more = await page.$(".b-tab__more")
|
||||
more && more.click()
|
||||
await page.$$eval(".b-tab__item", (list, text) => {
|
||||
console.log(list)
|
||||
for (let i of list) {
|
||||
if (i && i.innerText) {
|
||||
if (text == i.innerText.trim()) {
|
||||
i.click()
|
||||
}
|
||||
}
|
||||
}
|
||||
}, text)
|
||||
await seep(1000);
|
||||
}
|
||||
|
||||
list = await page.evaluate(() => {
|
||||
return __PINIA__.episodeMain
|
||||
})
|
||||
|
||||
list = list.listData[0].list
|
||||
let listData = []
|
||||
for (let i of list) {
|
||||
// listData.push(...i)
|
||||
i.forEach(j => {
|
||||
if(!j.isNoStoreWatchHistory){
|
||||
listData.push(j)
|
||||
}
|
||||
});
|
||||
}
|
||||
list = []
|
||||
for(let i of listData){
|
||||
list.push({
|
||||
title:i.fullTitle,
|
||||
url:"https://v.qq.com/x/cover/" + i.cid + "/" + i.vid + ".html"
|
||||
})
|
||||
}
|
||||
browser.close()
|
||||
return list
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getListData
|
||||
}
|
||||
20
util/preload.js
Normal file
20
util/preload.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const path = require('path')
|
||||
const { getListData } = require(path.join(__dirname,'/getList/qq.js'));
|
||||
const {dow} = require("./utils.js")
|
||||
|
||||
async function getlist (url) {
|
||||
let list = await getListData(url)
|
||||
return list
|
||||
// console.log('electron收到远端的传参', a);
|
||||
// callback('config result'); // 回调给远端的请求数据,如 config
|
||||
// ipcRenderer.send('close', 'args bbb'); // 比如收到请求关闭窗口
|
||||
};
|
||||
|
||||
window.getlist = getlist
|
||||
|
||||
|
||||
|
||||
window.dowload = function (info,callback){
|
||||
console.log("开始")
|
||||
dow(info,callback)
|
||||
}
|
||||
26
util/utils.js
Normal file
26
util/utils.js
Normal file
@@ -0,0 +1,26 @@
|
||||
const { spawn } = require('child_process');
|
||||
|
||||
|
||||
function seep(time){
|
||||
return new Promise((res)=>{
|
||||
setTimeout(()=>{
|
||||
res()
|
||||
},time)
|
||||
})
|
||||
}
|
||||
|
||||
function dow(info,callback){
|
||||
const lux = spawn("./bin/yt-dlp.exe", ['--cookies-from-browser', 'edge', '-P', 'D:/dl', '-o', info.title + '.mp4', info.url])
|
||||
lux.stdout.on('data', (data) => {
|
||||
callback(data,false)
|
||||
});
|
||||
lux.on('close', (code) => {
|
||||
console.log("结束")
|
||||
callback(code,true)
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
seep,
|
||||
dow
|
||||
}
|
||||
Reference in New Issue
Block a user