ptSend/util/sql/download.js

42 lines
950 B
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 isOk == 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 isOk = ? 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){
}
module.exports = {
addDownList,
getDownList,
setDownState
}