Merge branches 'master' and 'master' of https://git.theluyuan.com/luyuan/ptSend
This commit is contained in:
commit
4822d09dba
5
config.json
Normal file
5
config.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"downloadPath": "",
|
||||
"vCookies": "e",
|
||||
"torrentSavePath": ""
|
||||
}
|
4
index.js
4
index.js
@ -2,7 +2,7 @@ const Koa = require('koa');
|
||||
const app = new Koa();
|
||||
const static = require('koa-static')
|
||||
app.use(static("./view/dist"))
|
||||
const { koaBody } = require('koa-body');
|
||||
const {koaBody} = require('koa-body');
|
||||
const KoaSSEStream = require('koa-sse-stream');
|
||||
|
||||
app.use(koaBody());
|
||||
@ -20,7 +20,9 @@ app.use(async (ctx, next) => {
|
||||
const index = require("./router/index.js")
|
||||
app.use(index.routes()).use(index.allowedMethods())
|
||||
const videoInfo = require("./router/videoInfo.js");
|
||||
const config = require("./router/config.js")
|
||||
|
||||
app.use(config.routes()).use(config.allowedMethods())
|
||||
app.use(videoInfo.routes()).use(videoInfo.allowedMethods())
|
||||
app.listen(3050, "0.0.0.0");
|
||||
|
||||
|
43
router/config.js
Normal file
43
router/config.js
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
配置文件获取修改接口
|
||||
*/
|
||||
|
||||
const Router = require("koa-router")
|
||||
const config = require("../util/config/config")
|
||||
const router = new Router({
|
||||
prefix: "/config"
|
||||
})
|
||||
|
||||
/**
|
||||
* 获取配置文件接口
|
||||
*/
|
||||
router.get('/getConfig', async (ctx) => {
|
||||
let json = config.getConfig();
|
||||
const b = json === '{}'
|
||||
|
||||
ctx.body = {
|
||||
code: b ? -1 : 0,
|
||||
msg: b ? 'error' : "ok",
|
||||
data: json
|
||||
}
|
||||
})
|
||||
/**
|
||||
* 设置配置文件接口
|
||||
*/
|
||||
router.post('/setConfig', async (req, res) => {
|
||||
if (req.request.body === undefined) {
|
||||
req.body = {
|
||||
code: -1,
|
||||
msg: "提交内容不能为空"
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
let b = config.setConfig(req.request.body);
|
||||
req.body = {
|
||||
code: b ? 0 : -2,
|
||||
msg: b ? 'ok' : "error",
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = router
|
@ -9,7 +9,10 @@ const axios = require("axios");
|
||||
const router = new Router()
|
||||
// const download = []
|
||||
|
||||
// 豆瓣img代理
|
||||
|
||||
/**
|
||||
* 豆瓣img代理
|
||||
*/
|
||||
router.get("/doubanImg",async (ctx)=>{
|
||||
let url = ctx.query.url
|
||||
let res = await axios.get(url,{
|
||||
@ -23,6 +26,9 @@ router.get("/doubanImg",async (ctx)=>{
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* 功能测试接口
|
||||
*/
|
||||
router.get("/test", async (ctx) => {
|
||||
// let res = await utils.uploadImg('C:/Users/11629/Desktop/80032464_p0.jpg')
|
||||
// ctx.body = {
|
||||
@ -34,7 +40,9 @@ router.get("/test", async (ctx) => {
|
||||
})
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 视频文件信息获取
|
||||
*/
|
||||
router.get("/getMediaInfo", async (ctx) => {
|
||||
let url = ctx.query.filePath
|
||||
let data
|
||||
@ -50,6 +58,9 @@ router.get("/getMediaInfo", async (ctx) => {
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* 不知道干嘛的
|
||||
*/
|
||||
router.get("/getQqList", async (ctx) => {
|
||||
let url = ctx.query.url
|
||||
let video_id = url.split("/")
|
||||
@ -62,6 +73,9 @@ router.get("/getQqList", async (ctx) => {
|
||||
ctx.body = await getQqListData(url)
|
||||
})
|
||||
|
||||
/**
|
||||
* 不知道干嘛的
|
||||
*/
|
||||
router.get("/startDown", async (ctx) => {
|
||||
let title = ctx.query.title
|
||||
let url = ctx.query.url
|
||||
@ -86,6 +100,10 @@ const SSE_CONF = {
|
||||
maxClients: 5, // 最大连接数
|
||||
pingInterval: 40000 // 重连时间
|
||||
}
|
||||
|
||||
/**
|
||||
* 还是不知道干嘛的
|
||||
*/
|
||||
router.get('/msg', KoaSSEStream(SSE_CONF), ctx => {
|
||||
// 每次连接会进行一个 push
|
||||
clientList.push(ctx.sse);
|
||||
|
@ -1,5 +1,5 @@
|
||||
const Router = require("koa-router")
|
||||
const { serach, gen_douban } = require("../util/ptgen")
|
||||
const {search, gen_douban} = require("../util/ptgen")
|
||||
const axios = require("axios")
|
||||
const cheerio = require("cheerio");
|
||||
const {addSub, getSub, delSub} = require("../util/sql/video"); // HTML页面解析
|
||||
@ -8,24 +8,18 @@ const router = new Router({
|
||||
prefix: "/videoInfo"
|
||||
})
|
||||
|
||||
|
||||
router.get("/search", async (ctx) => {
|
||||
let name = ctx.query.name
|
||||
ctx.body = await serach(name)
|
||||
})
|
||||
|
||||
// router.get("/getinfo",async (ctx)=>{
|
||||
// let url = ctx.query.url
|
||||
// let info = await getinfo(url)
|
||||
// ctx.body = info
|
||||
// })
|
||||
|
||||
/**
|
||||
* 豆瓣搜索
|
||||
*/
|
||||
router.get("/searchVideo", async (ctx) => {
|
||||
let name = ctx.query.name
|
||||
ctx.body = await serach(name)
|
||||
ctx.body = await search(name)
|
||||
|
||||
})
|
||||
|
||||
/**
|
||||
* 获取豆瓣描述
|
||||
*/
|
||||
router.get("/getVideoInfo", async (ctx) => {
|
||||
let id = ctx.query.id
|
||||
if (!id) {
|
||||
@ -36,31 +30,39 @@ router.get("/getVideoInfo", async (ctx) => {
|
||||
|
||||
})
|
||||
|
||||
/**
|
||||
* 添加订阅
|
||||
*/
|
||||
router.post("/addSubscribe", async (ctx) => {
|
||||
// console.log(ctx.request.body)
|
||||
let data = ctx.request.body
|
||||
try {
|
||||
let r = await addSub(data)
|
||||
if(r){
|
||||
if (r) {
|
||||
ctx.body = "订阅已存在"
|
||||
}else{
|
||||
} else {
|
||||
ctx.body = "添加成功"
|
||||
}
|
||||
}catch {
|
||||
} catch {
|
||||
ctx.body = "添加失败"
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
router.get("/getSubscribe",async (ctx)=>{
|
||||
let list = await getSub()
|
||||
ctx.body = list
|
||||
/**
|
||||
* 获取订阅列表
|
||||
*/
|
||||
router.get("/getSubscribe", async (ctx) => {
|
||||
ctx.body = await getSub()
|
||||
})
|
||||
|
||||
/**
|
||||
* 从imdb获取影视英文名称
|
||||
*/
|
||||
router.get("/getImdbName", async (ctx) => {
|
||||
let res = await axios.get(ctx.query.url, {
|
||||
proxy: false,
|
||||
headers:{
|
||||
headers: {
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.67"
|
||||
}
|
||||
})
|
||||
@ -70,12 +72,21 @@ router.get("/getImdbName", async (ctx) => {
|
||||
ctx.body = $("h1").text()
|
||||
})
|
||||
|
||||
router.get("/delSubscribe",async (ctx)=>{
|
||||
/**
|
||||
* 删除订阅任务
|
||||
*/
|
||||
router.get("/delSubscribe", async (ctx) => {
|
||||
try {
|
||||
await delSub(ctx.query.id)
|
||||
ctx.body = "删除成功"
|
||||
}catch {
|
||||
ctx.body = "删除失败"
|
||||
ctx.body = {
|
||||
code: 0,
|
||||
msg: "删除成功"
|
||||
}
|
||||
} catch {
|
||||
ctx.body = {
|
||||
code: 0,
|
||||
msg: "删除失败"
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
31
util/config/config.js
Normal file
31
util/config/config.js
Normal file
@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
|
||||
const fs = require("fs");
|
||||
const {cwd} = require("process");
|
||||
const path = require('path');
|
||||
let configPath = path.join(cwd(), "/config.json");
|
||||
|
||||
/**
|
||||
* 获取配置文件
|
||||
* @returns {JSON}
|
||||
*/
|
||||
function getConfig() {
|
||||
let file = fs.readFileSync(configPath);
|
||||
return JSON.parse(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存配置文件
|
||||
* @param config{String}
|
||||
* @return {boolean}
|
||||
*/
|
||||
function setConfig(config) {
|
||||
const data = JSON.stringify(config, null, 2)
|
||||
fs.writeFileSync("config.json", data);
|
||||
return JSON.stringify(getConfig(), null, 2) === data
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getConfig,
|
||||
setConfig
|
||||
}
|
1
view/dist/assets/index-6ef103ac.css
vendored
1
view/dist/assets/index-6ef103ac.css
vendored
File diff suppressed because one or more lines are too long
4
view/dist/index.html
vendored
4
view/dist/index.html
vendored
@ -6,8 +6,8 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vite + Vue</title>
|
||||
<meta name="referrer" content="never">
|
||||
<script type="module" crossorigin src="./assets/index-b619957d.js"></script>
|
||||
<link rel="stylesheet" href="./assets/index-6ef103ac.css">
|
||||
<script type="module" crossorigin src="./assets/index-ccfbebb1.js"></script>
|
||||
<link rel="stylesheet" href="./assets/index-e0450ab1.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
@ -128,7 +128,7 @@ async function getInfo(id, i) {
|
||||
vid = id
|
||||
img.value = i
|
||||
let res = await getVideoInfo(id)
|
||||
info.value = res.data.format
|
||||
info.value = res.data.format.replace('img1.doubanio','img9.doubanio')
|
||||
year.value = res.data.year
|
||||
imdb = res.data.imdb_link || ""
|
||||
console.info(res.data.trans_title.length)
|
||||
|
Loading…
Reference in New Issue
Block a user