add 添加订阅
This commit is contained in:
parent
a9428fe8ce
commit
25e68ab1d0
BIN
db/database.db
BIN
db/database.db
Binary file not shown.
@ -1,7 +1,8 @@
|
|||||||
const Router = require("koa-router")
|
const Router = require("koa-router")
|
||||||
const { serach, gen_douban } = require("../util/ptgen")
|
const { serach, gen_douban } = require("../util/ptgen")
|
||||||
const axios = require("axios")
|
const axios = require("axios")
|
||||||
const cheerio = require("cheerio"); // HTML页面解析
|
const cheerio = require("cheerio");
|
||||||
|
const {addSub} = require("../util/sql/video"); // HTML页面解析
|
||||||
|
|
||||||
const router = new Router({
|
const router = new Router({
|
||||||
prefix: "/videoInfo"
|
prefix: "/videoInfo"
|
||||||
@ -38,6 +39,16 @@ router.get("/getVideoInfo", async (ctx) => {
|
|||||||
router.post("/addSubscribe", async (ctx) => {
|
router.post("/addSubscribe", async (ctx) => {
|
||||||
// console.log(ctx.request.body)
|
// console.log(ctx.request.body)
|
||||||
let data = ctx.request.body
|
let data = ctx.request.body
|
||||||
|
try {
|
||||||
|
let r = await addSub(data)
|
||||||
|
if(r){
|
||||||
|
ctx.body = "订阅已存在"
|
||||||
|
}else{
|
||||||
|
ctx.body = "添加成功"
|
||||||
|
}
|
||||||
|
}catch {
|
||||||
|
ctx.body = "添加失败"
|
||||||
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,6 +1,18 @@
|
|||||||
const { run, getAll } = require("./base");
|
const { run, getAll } = require("./base");
|
||||||
|
const dayjs = require("dayjs");
|
||||||
|
|
||||||
function addSub(info){
|
async function addSub(info){
|
||||||
let sql = `insert into download(name,rename,skip,desc,url,subtitle,img) values(?,?,?,?,?,?)`
|
|
||||||
|
|
||||||
|
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
|
||||||
}
|
}
|
@ -25,6 +25,6 @@ export async function getImdbName(url) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function 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, desc, year, season, ep, url})
|
return await base.post("/videoInfo/addSubscribe", {name, rename, desc, year, season, ep, url, img, subtitle, time,skip,sid})
|
||||||
}
|
}
|
@ -36,6 +36,10 @@
|
|||||||
地址:
|
地址:
|
||||||
<el-input style="width: 80%" v-model="url"></el-input>
|
<el-input style="width: 80%" v-model="url"></el-input>
|
||||||
</div>
|
</div>
|
||||||
|
<div style="display: flex;align-items: center;padding: 5px">
|
||||||
|
检查更新时间:
|
||||||
|
<el-time-picker v-model="time" placeholder="Arbitrary time"/>
|
||||||
|
</div>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<span class="dialog-footer">
|
<span class="dialog-footer">
|
||||||
<el-button @click="dialogFormVisible = false">关闭</el-button>
|
<el-button @click="dialogFormVisible = false">关闭</el-button>
|
||||||
@ -52,7 +56,8 @@
|
|||||||
import {ref} from 'vue';
|
import {ref} from 'vue';
|
||||||
import {addSubscribe, getImdbName, getVideoInfo, searchVideo} from '../../api/Video.js'
|
import {addSubscribe, getImdbName, getVideoInfo, searchVideo} from '../../api/Video.js'
|
||||||
import {onBeforeRouteUpdate, useRoute} from "vue-router";
|
import {onBeforeRouteUpdate, useRoute} from "vue-router";
|
||||||
import {ElLoading} from "element-plus";
|
import {ElLoading, ElMessage} from "element-plus";
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
let list = ref([])
|
let list = ref([])
|
||||||
const info = ref("")
|
const info = ref("")
|
||||||
@ -63,6 +68,8 @@ const season = ref(1)
|
|||||||
const url = ref("")
|
const url = ref("")
|
||||||
const subtitle = ref("")
|
const subtitle = ref("")
|
||||||
const img = ref("")
|
const img = ref("")
|
||||||
|
const time = ref("")
|
||||||
|
const name = ref("")
|
||||||
async function onSubmit(name) {
|
async function onSubmit(name) {
|
||||||
let res = await searchVideo(name)
|
let res = await searchVideo(name)
|
||||||
list.value = res.data.data
|
list.value = res.data.data
|
||||||
@ -79,7 +86,7 @@ let vid = "";
|
|||||||
const dialogFormVisible = ref(false)
|
const dialogFormVisible = ref(false)
|
||||||
|
|
||||||
|
|
||||||
async function getInfo(id,i) {
|
async function getInfo(id, i) {
|
||||||
const loadingInstance = ElLoading.service({fullscreen: true})
|
const loadingInstance = ElLoading.service({fullscreen: true})
|
||||||
vid = id
|
vid = id
|
||||||
img.value = i
|
img.value = i
|
||||||
@ -87,7 +94,11 @@ async function getInfo(id,i) {
|
|||||||
info.value = res.data.format
|
info.value = res.data.format
|
||||||
year.value = res.data.year
|
year.value = res.data.year
|
||||||
subtitle.value = res.data.trans_title.join(" / ")
|
subtitle.value = res.data.trans_title.join(" / ")
|
||||||
await subscribe(res.data.imdb_link)
|
name.value = res.data.chinese_title
|
||||||
|
enName.value = ""
|
||||||
|
if(res.data.imdb_link){
|
||||||
|
await subscribe(res.data.imdb_link)
|
||||||
|
}
|
||||||
dialogFormVisible.value = true
|
dialogFormVisible.value = true
|
||||||
loadingInstance.close()
|
loadingInstance.close()
|
||||||
}
|
}
|
||||||
@ -100,16 +111,41 @@ async function subscribe(url) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function addsubscribe() {
|
async function addsubscribe() {
|
||||||
addSubscribe({
|
let data = {
|
||||||
name: enName.value,
|
name: name.value,
|
||||||
|
rename: enName.value,
|
||||||
desc: info.value,
|
desc: info.value,
|
||||||
year: year.value,
|
year: year.value,
|
||||||
season: season.value,
|
season: season.value,
|
||||||
ep: ep.value,
|
ep: ep.value,
|
||||||
url: url.value,
|
url: url.value,
|
||||||
img:img.value,
|
img: img.value,
|
||||||
subtitle:subtitle.value
|
subtitle: subtitle.value,
|
||||||
})
|
time: dayjs(time.value).format("HH:mm:ss"),
|
||||||
|
skip:season.value,
|
||||||
|
sid:vid
|
||||||
|
}
|
||||||
|
for(let i in data){
|
||||||
|
if(!data[i]){
|
||||||
|
ElMessage({
|
||||||
|
message: '请完整填写内容!',
|
||||||
|
type: 'error',
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let res = await addSubscribe(data)
|
||||||
|
if(res.data == "添加成功"){
|
||||||
|
ElMessage({
|
||||||
|
message: res.data,
|
||||||
|
type: 'success',
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
ElMessage({
|
||||||
|
message: res.data,
|
||||||
|
type: 'error',
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user