From 8b7af9535cecb641b34ce97d247fe858c7ec8637 Mon Sep 17 00:00:00 2001 From: theluyuan <1162963624@qq.com> Date: Sun, 3 Sep 2023 16:59:13 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E7=B3=BB=E7=BB=9F=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E9=85=8D=E7=BD=AEcookies=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=8F=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +- config.json | 5 --- util/SendSeed/index.js | 36 +++++++++++---------- util/Video/Update.js | 5 +-- util/sql/video.js | 1 - view/src/api/Config.js | 10 ++++++ view/src/page/settings.vue | 45 ++++++++++++++++++++------- view/src/page/subscribe/subscribe.vue | 2 +- 8 files changed, 69 insertions(+), 38 deletions(-) delete mode 100644 config.json create mode 100644 view/src/api/Config.js diff --git a/.gitignore b/.gitignore index 011685b..08178f7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules/ view/node_modules/ .idea/ -/db/database.db \ No newline at end of file +/db/database.db +/config.json \ No newline at end of file diff --git a/config.json b/config.json deleted file mode 100644 index e4efe0c..0000000 --- a/config.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "downloadPath": "", - "vCookies": "e", - "torrentSavePath": "" -} \ No newline at end of file diff --git a/util/SendSeed/index.js b/util/SendSeed/index.js index e31fe69..2876407 100644 --- a/util/SendSeed/index.js +++ b/util/SendSeed/index.js @@ -7,8 +7,9 @@ const { getVideoInfo } = require("../sql/video.js"); const { mkdirRecursions } = require("../markdir.js"); const { default: axios } = require("axios"); const FormData = require('form-data'); -let newDir = "K:/zuozhongtest" -function getId(url){ +const { getConfig } = require("../config/config.js"); +// let newDir = "K:/zuozhongtest" +function getId(url) { // 1; url=download.php?id=10796 return url.split("?")[1].split("=")[1] } @@ -18,16 +19,16 @@ async function updateSeed(info, desc) { form.append('file', fs.createReadStream(path.join(cwd(), "/tmp/torrent/" + info.seedName.replace(/\s+/g, '.') + ".torrent"))) let ep = await getDownEp(info.vid) console.log(ep) - if(ep.start == ep.end){ + if (ep.start == ep.end) { form.append("name", info.title.replace("Epxxx", "E" + info.ep)) - }else{ - if(ep.start == 1 && ep.end == vinfo.count){ + } else { + if (ep.start == 1 && ep.end == vinfo.count) { form.append("name", info.title.replace("Epxxx", "")) - }else{ + } else { form.append("name", info.title.replace("Epxxx", "E" + ep.start + "-" + "E" + ep.end)) } } - await setDownStateVid(info.vid,2) + await setDownStateVid(info.vid, 2) form.append("small_descr", vinfo.subtitle) form.append("url", vinfo.imdb) form.append("descr", desc) @@ -39,7 +40,7 @@ async function updateSeed(info, desc) { } form.append("medium_sel[4]", "10") form.append("team_sel[4]", "7") - form.append("uplver","yes") + form.append("uplver", "yes") let fbl = { 4320: "9", 2160: "5", @@ -50,23 +51,23 @@ async function updateSeed(info, desc) { } form.append("standard_sel[4]", fbl[info.fbl]) let instance = axios.create({ - headers: {...form.getHeaders(),Cookie:"c_secure_uid=MTQwMzg%3D; c_secure_pass=166f7662c2f2b83df7bfab6707e1af7d; c_secure_ssl=eWVhaA%3D%3D; c_secure_tracker_ssl=eWVhaA%3D%3D; c_secure_login=bm9wZQ%3D%3D"} - }); + headers: { ...form.getHeaders(), Cookie: getConfig().vCookies } + }); let res = await instance.post("https://zmpt.cc/takeupload.php", form, { proxy: false }) console.log(res.headers.refresh) instance = axios.create({ - headers: {Cookie:"c_secure_uid=MTQwMzg%3D; c_secure_pass=166f7662c2f2b83df7bfab6707e1af7d; c_secure_ssl=eWVhaA%3D%3D; c_secure_tracker_ssl=eWVhaA%3D%3D; c_secure_login=bm9wZQ%3D%3D"} - }); + headers: { Cookie: getConfig().vCookies } + }); await instance({ method: 'get', url: "https://zmpt.cc/download.php?id=" + getId(res.headers.refresh), responseType: 'stream', proxy: false - }).then(response => { + }).then(response => { response.data.pipe(fs.createWriteStream(path.join(cwd(), `/downtor/${new Date().getTime()}.torrent`))); - }) + }) } async function createDesc(filepath, vid) { @@ -89,7 +90,7 @@ async function sendSeed(info) { let state = await getMediaState(info.vid) console.log(state) if (state) { - // 删除tmp + // 删除tmp await deleteFolder(path.join(cwd(), "/tmp")) await mkdirRecursions(path.join(cwd(), "/tmp/torrent/")) await mkdirRecursions(path.join(cwd(), "/downtor/")) @@ -112,14 +113,15 @@ async function sendSeed(info) { // 发种 await updateSeed(info, desc) - } catch(err) { + } catch (err) { console.log(err) console.log("发种失败") } + let newDir = getConfig().torrentSavePath // 移动到做种文件夹 mkdirRecursions(newDir + "/" + info.seedName + "/") // fs.renameSync(info.newPath + "/" + info.rname, newDir + "/" + info.seedName + "/" + info.rname); - moveDir(info.newPath + "/" ,newDir + "/" + info.seedName + "/") + moveDir(info.newPath + "/", newDir + "/" + info.seedName + "/") // 删除下载的文件夹 deleteFolder(info.newPath) } else { diff --git a/util/Video/Update.js b/util/Video/Update.js index db968b9..83ad09a 100644 --- a/util/Video/Update.js +++ b/util/Video/Update.js @@ -1,7 +1,8 @@ const schedule = require('node-schedule'); const { getSub,updateSkip } = require('../sql/video'); const { getQqListData } = require("../getList/qq.js") -const { addDownList } = require("../sql/download.js") +const { addDownList } = require("../sql/download.js"); +const { getConfig } = require('../config/config'); // 检查更新并将更新推送下载 async function addDown(i) { @@ -20,7 +21,7 @@ async function addDown(i) { } for (let j = i.skip - 1; j < newlist.length; j++) { let v = newlist[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 addDownList(v.item_params.title, `https://v.qq.com/x/cover/${cid}/${v.item_params.vid}.html`, `${getConfig().downloadPath}/${i.sid}`, new Date().getTime(), 0, i.sid) } await updateSkip(list.length + 1,i.id) // console.log(JSON.stringify(list)) diff --git a/util/sql/video.js b/util/sql/video.js index f2f34a5..795dc81 100644 --- a/util/sql/video.js +++ b/util/sql/video.js @@ -63,7 +63,6 @@ async function getVideoInfoById(id){ } } - module.exports = { addSub, getSub, diff --git a/view/src/api/Config.js b/view/src/api/Config.js new file mode 100644 index 0000000..0312560 --- /dev/null +++ b/view/src/api/Config.js @@ -0,0 +1,10 @@ +import {base} from "./base"; + + +export async function setConfig(data){ + return await base.post('/config/setConfig',data) +} + +export async function getConfig(){ + return await base.get('/config/getConfig') +} \ No newline at end of file diff --git a/view/src/page/settings.vue b/view/src/page/settings.vue index 210b96a..51cb164 100644 --- a/view/src/page/settings.vue +++ b/view/src/page/settings.vue @@ -1,16 +1,39 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/view/src/page/subscribe/subscribe.vue b/view/src/page/subscribe/subscribe.vue index 15030ee..94d464a 100644 --- a/view/src/page/subscribe/subscribe.vue +++ b/view/src/page/subscribe/subscribe.vue @@ -21,7 +21,7 @@ import {onMounted, ref} from "vue"; import {delSubscribe, getSubscribe} from '../../api/Video.js' import {ElMessage, ElMessageBox} from "element-plus"; -const list = ref([]) +const list = ref([]) onMounted(async ()=>{ const res = await getSubscribe() list.value = res.data