diff --git a/db/database.db b/db/database.db index e54188a..70ce26c 100644 Binary files a/db/database.db and b/db/database.db differ diff --git a/router/videoInfo.js b/router/videoInfo.js index 97b2643..e291972 100644 --- a/router/videoInfo.js +++ b/router/videoInfo.js @@ -1,7 +1,8 @@ const Router = require("koa-router") const { serach, gen_douban } = require("../util/ptgen") const axios = require("axios") -const cheerio = require("cheerio"); // HTML页面解析 +const cheerio = require("cheerio"); +const {addSub} = require("../util/sql/video"); // HTML页面解析 const router = new Router({ prefix: "/videoInfo" @@ -38,6 +39,16 @@ 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){ + ctx.body = "订阅已存在" + }else{ + ctx.body = "添加成功" + } + }catch { + ctx.body = "添加失败" + } }) diff --git a/util/sql/video.js b/util/sql/video.js index ba9a851..a0edda3 100644 --- a/util/sql/video.js +++ b/util/sql/video.js @@ -1,6 +1,18 @@ const { run, getAll } = require("./base"); +const dayjs = require("dayjs"); -function addSub(info){ - let sql = `insert into download(name,rename,skip,desc,url,subtitle,img) values(?,?,?,?,?,?)` +async function addSub(info){ + let selSql = `select * from VideoInfo where sid='${info.sid}' and season=${info.season}` + let list = await getAll(selSql) + if(list.length != 0){ + return "订阅已存在" + } + let sql = `insert into VideoInfo(name,rename,skip,desc,url,subtitle,img,year,time,subTime,enable,season,sid) values(?,?,?,?,?,?,?,?,?,${new Date().getTime()},1,?,?)` + await run(sql,info.name,info.rename,info.skip,info.desc,info.url,info.subtitle,info.img,info.year,info.time,info.season,info.sid) +} + + +module.exports = { + addSub } \ No newline at end of file diff --git a/view/src/api/Video.js b/view/src/api/Video.js index 7e3442a..993960d 100644 --- a/view/src/api/Video.js +++ b/view/src/api/Video.js @@ -25,6 +25,6 @@ export async function getImdbName(url) { }) } -export async function addSubscribe({name, desc, year, season, ep, url}) { - return await base.post("/videoInfo/addSubscribe", {name, desc, year, season, ep, url}) +export async function addSubscribe({name, rename, desc, year, season, ep, url, img, subtitle, time,skip,sid}) { + return await base.post("/videoInfo/addSubscribe", {name, rename, desc, year, season, ep, url, img, subtitle, time,skip,sid}) } \ No newline at end of file diff --git a/view/src/page/subscribe/addSubscribe.vue b/view/src/page/subscribe/addSubscribe.vue index a2103a3..947309d 100644 --- a/view/src/page/subscribe/addSubscribe.vue +++ b/view/src/page/subscribe/addSubscribe.vue @@ -36,6 +36,10 @@ 地址: +
+ 检查更新时间: + +