add 系统下载地址配置cookies配置及

This commit is contained in:
theluyuan 2023-09-03 16:59:13 +08:00
parent f5c666a027
commit 8b7af9535c
8 changed files with 69 additions and 38 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ node_modules/
view/node_modules/ view/node_modules/
.idea/ .idea/
/db/database.db /db/database.db
/config.json

View File

@ -1,5 +0,0 @@
{
"downloadPath": "",
"vCookies": "e",
"torrentSavePath": ""
}

View File

@ -7,8 +7,9 @@ const { getVideoInfo } = require("../sql/video.js");
const { mkdirRecursions } = require("../markdir.js"); const { mkdirRecursions } = require("../markdir.js");
const { default: axios } = require("axios"); const { default: axios } = require("axios");
const FormData = require('form-data'); const FormData = require('form-data');
let newDir = "K:/zuozhongtest" const { getConfig } = require("../config/config.js");
function getId(url){ // let newDir = "K:/zuozhongtest"
function getId(url) {
// 1; url=download.php?id=10796 // 1; url=download.php?id=10796
return url.split("?")[1].split("=")[1] 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"))) form.append('file', fs.createReadStream(path.join(cwd(), "/tmp/torrent/" + info.seedName.replace(/\s+/g, '.') + ".torrent")))
let ep = await getDownEp(info.vid) let ep = await getDownEp(info.vid)
console.log(ep) console.log(ep)
if(ep.start == ep.end){ if (ep.start == ep.end) {
form.append("name", info.title.replace("Epxxx", "E" + info.ep)) form.append("name", info.title.replace("Epxxx", "E" + info.ep))
}else{ } else {
if(ep.start == 1 && ep.end == vinfo.count){ if (ep.start == 1 && ep.end == vinfo.count) {
form.append("name", info.title.replace("Epxxx", "")) form.append("name", info.title.replace("Epxxx", ""))
}else{ } else {
form.append("name", info.title.replace("Epxxx", "E" + ep.start + "-" + "E" + ep.end)) 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("small_descr", vinfo.subtitle)
form.append("url", vinfo.imdb) form.append("url", vinfo.imdb)
form.append("descr", desc) form.append("descr", desc)
@ -39,7 +40,7 @@ async function updateSeed(info, desc) {
} }
form.append("medium_sel[4]", "10") form.append("medium_sel[4]", "10")
form.append("team_sel[4]", "7") form.append("team_sel[4]", "7")
form.append("uplver","yes") form.append("uplver", "yes")
let fbl = { let fbl = {
4320: "9", 4320: "9",
2160: "5", 2160: "5",
@ -50,23 +51,23 @@ async function updateSeed(info, desc) {
} }
form.append("standard_sel[4]", fbl[info.fbl]) form.append("standard_sel[4]", fbl[info.fbl])
let instance = axios.create({ 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, { let res = await instance.post("https://zmpt.cc/takeupload.php", form, {
proxy: false proxy: false
}) })
console.log(res.headers.refresh) console.log(res.headers.refresh)
instance = axios.create({ 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({ await instance({
method: 'get', method: 'get',
url: "https://zmpt.cc/download.php?id=" + getId(res.headers.refresh), url: "https://zmpt.cc/download.php?id=" + getId(res.headers.refresh),
responseType: 'stream', responseType: 'stream',
proxy: false proxy: false
}).then(response => { }).then(response => {
response.data.pipe(fs.createWriteStream(path.join(cwd(), `/downtor/${new Date().getTime()}.torrent`))); response.data.pipe(fs.createWriteStream(path.join(cwd(), `/downtor/${new Date().getTime()}.torrent`)));
}) })
} }
async function createDesc(filepath, vid) { async function createDesc(filepath, vid) {
@ -89,7 +90,7 @@ async function sendSeed(info) {
let state = await getMediaState(info.vid) let state = await getMediaState(info.vid)
console.log(state) console.log(state)
if (state) { if (state) {
// 删除tmp // 删除tmp
await deleteFolder(path.join(cwd(), "/tmp")) await deleteFolder(path.join(cwd(), "/tmp"))
await mkdirRecursions(path.join(cwd(), "/tmp/torrent/")) await mkdirRecursions(path.join(cwd(), "/tmp/torrent/"))
await mkdirRecursions(path.join(cwd(), "/downtor/")) await mkdirRecursions(path.join(cwd(), "/downtor/"))
@ -112,14 +113,15 @@ async function sendSeed(info) {
// 发种 // 发种
await updateSeed(info, desc) await updateSeed(info, desc)
} catch(err) { } catch (err) {
console.log(err) console.log(err)
console.log("发种失败") console.log("发种失败")
} }
let newDir = getConfig().torrentSavePath
// 移动到做种文件夹 // 移动到做种文件夹
mkdirRecursions(newDir + "/" + info.seedName + "/") mkdirRecursions(newDir + "/" + info.seedName + "/")
// fs.renameSync(info.newPath + "/" + info.rname, newDir + "/" + info.seedName + "/" + info.rname); // 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) deleteFolder(info.newPath)
} else { } else {

View File

@ -1,7 +1,8 @@
const schedule = require('node-schedule'); const schedule = require('node-schedule');
const { getSub,updateSkip } = require('../sql/video'); const { getSub,updateSkip } = require('../sql/video');
const { getQqListData } = require("../getList/qq.js") 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) { async function addDown(i) {
@ -20,7 +21,7 @@ async function addDown(i) {
} }
for (let j = i.skip - 1; j < newlist.length; j++) { for (let j = i.skip - 1; j < newlist.length; j++) {
let v = newlist[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) await updateSkip(list.length + 1,i.id)
// console.log(JSON.stringify(list)) // console.log(JSON.stringify(list))

View File

@ -63,7 +63,6 @@ async function getVideoInfoById(id){
} }
} }
module.exports = { module.exports = {
addSub, addSub,
getSub, getSub,

10
view/src/api/Config.js Normal file
View File

@ -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')
}

View File

@ -1,16 +1,39 @@
<script setup> <script setup>
import { ref } from 'vue';
import {setConfig,getConfig} from "../api/Config.js"
import { ElMessage } from 'element-plus'
const formLabelAlign = ref({})
function submitForm(){
setConfig(formLabelAlign.value).then((res)=>{
ElMessage({
message: '保存成功',
type: 'success',
})
console.log(res)
})
}
getConfig().then((res)=>{
console.log(res)
formLabelAlign.value = res.data.data
})
</script> </script>
<template> <template>
<el-row :gutter="20"> <el-form :label-position="labelPosition" label-width="100px" :model="formLabelAlign" style="max-width: 460px">
<h1 style="padding: 20px">设置页面</h1> <el-form-item label="临时下载地址">
<el-divider /> <el-input v-model="formLabelAlign.downloadPath" />
</el-row> </el-form-item>
<el-form-item label="做种位置">
<el-input v-model="formLabelAlign.torrentSavePath" />
</el-form-item>
<el-form-item label="zmptCookies">
<el-input v-model="formLabelAlign.vCookies" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submitForm()">
保存
</el-button>
</el-form-item>
</el-form>
</template> </template>
<style> <style></style>
</style>

View File

@ -21,7 +21,7 @@ import {onMounted, ref} from "vue";
import {delSubscribe, getSubscribe} from '../../api/Video.js' import {delSubscribe, getSubscribe} from '../../api/Video.js'
import {ElMessage, ElMessageBox} from "element-plus"; import {ElMessage, ElMessageBox} from "element-plus";
const list = ref([]) const list = ref<any>([])
onMounted(async ()=>{ onMounted(async ()=>{
const res = await getSubscribe() const res = await getSubscribe()
list.value = res.data list.value = res.data