ptSend/util/sql/video.js

31 lines
901 B
JavaScript
Raw Normal View History

2023-07-12 16:21:57 +08:00
const { run, getAll } = require("./base");
2023-07-12 20:41:05 +08:00
const dayjs = require("dayjs");
2023-07-12 16:21:57 +08:00
2023-07-12 20:41:05 +08:00
async function addSub(info){
2023-07-12 16:21:57 +08:00
2023-07-12 20:41:05 +08:00
let selSql = `select * from VideoInfo where sid='${info.sid}' and season=${info.season}`
let list = await getAll(selSql)
if(list.length != 0){
return "订阅已存在"
}
2023-07-13 09:44:47 +08:00
let sql = `insert into VideoInfo(name,rename,skip,desc,url,subtitle,img,year,time,subTime,enable,season,sid,count) 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,info.count)
}
async function getSub(){
let sql = `select * from VideoInfo`
let list = await getAll(sql)
return list
2023-07-12 20:41:05 +08:00
}
2023-07-13 10:05:32 +08:00
async function delSub(id){
let sql = `delete from VideoInfo where id=${id}`
await run(sql)
}
2023-07-12 20:41:05 +08:00
module.exports = {
2023-07-13 09:44:47 +08:00
addSub,
2023-07-13 10:05:32 +08:00
getSub,
delSub
2023-07-12 16:21:57 +08:00
}