ptSend/util/sql/download.js
2023-08-07 22:05:55 +08:00

52 lines
1.2 KiB
JavaScript

const { run, getAll } = require("./base");
// state 0未下载 1下载完成 2已发种
function addDownList(title,url,save,downDate,state,vid){
let sql = `insert into download(title,url,save,downDate,state,vid) values(?,?,?,?,?,?)`
run(sql,title,url,save,downDate,state,vid)
}
async function getDownList(){
let sql = `select * from download where state == 0`
try{
let list = await getAll(sql)
return list
}catch(err){
console.error(err)
return []
}
}
async function setDownState(id,state){
let sql = `update download set state = ? where id = ?`
await run(sql,state,id)
}
async function getVideoInfo(url){
if(url){
let sql = `select * from VideoInfo where url = '?'`
let list = await getAll(sql,url)
}else{
let sql = `insert into `
}
}
async function addVideoInfo(cover){
}
// 获取当前剧集是否下载完成
// todo 多集连发
async function getMediaState(vid){
let sql = `select * from download where vid=? and state!=1`
let list = await getAll(sql,vid)
return !list.length
// return true
}
module.exports = {
addDownList,
getDownList,
setDownState,
getMediaState
}