ptSend/util/sql/download.js

52 lines
1.2 KiB
JavaScript
Raw Normal View History

2023-06-28 21:11:21 +08:00
const { run, getAll } = require("./base");
2023-06-20 22:34:27 +08:00
2023-07-22 15:56:26 +08:00
// 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)
2023-06-28 21:11:21 +08:00
}
async function getDownList(){
2023-07-22 23:04:26 +08:00
let sql = `select * from download where state == 0`
2023-06-28 21:11:21 +08:00
try{
let list = await getAll(sql)
return list
}catch(err){
console.error(err)
return []
}
}
async function setDownState(id,state){
2023-07-22 23:04:26 +08:00
let sql = `update download set state = ? where id = ?`
2023-06-28 21:11:21 +08:00
await run(sql,state,id)
}
2023-06-29 21:59:57 +08:00
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){
}
2023-07-23 01:03:29 +08:00
// 获取当前剧集是否下载完成
// todo 多集连发
2023-07-23 01:03:29 +08:00
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
2023-07-23 01:03:29 +08:00
}
2023-06-28 21:11:21 +08:00
module.exports = {
addDownList,
getDownList,
2023-07-23 01:03:29 +08:00
setDownState,
getMediaState
2023-06-20 22:34:27 +08:00
}