const { run, getAll } = require("./base");

function addDownList(title,url,save,downDate,isOk,vid){
    let sql = `insert into download(title,url,save,downDate,isOk,vid) values(?,?,?,?,?,?)`
    run(sql,title,url,save,downDate,isOk,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
}