add 添加订阅

This commit is contained in:
2023-07-12 20:41:05 +08:00
parent a9428fe8ce
commit 25e68ab1d0
5 changed files with 72 additions and 13 deletions

View File

@@ -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 = "添加失败"
}
})