add 打包发布
This commit is contained in:
		
							parent
							
								
									b675e3033d
								
							
						
					
					
						commit
						007c76ccd3
					
				
							
								
								
									
										
											BIN
										
									
								
								db/database.db
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								db/database.db
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							@ -1,5 +1,5 @@
 | 
			
		||||
const fs = require("fs")
 | 
			
		||||
const { getMediaState } = require("../sql/download.js");
 | 
			
		||||
const { getMediaState, getDownEp } = require("../sql/download.js");
 | 
			
		||||
const path = require("path");
 | 
			
		||||
const { cwd } = require("process");
 | 
			
		||||
const { createTorrent, getVideoSpecifyTimeImage, uploadImg, getMediaInfoSend, deleteFolder, moveDir } = require("../utils.js");
 | 
			
		||||
@ -16,11 +16,17 @@ async function updateSeed(info, desc) {
 | 
			
		||||
    let vinfo = await getVideoInfo(info.vid)
 | 
			
		||||
    let form = new FormData()
 | 
			
		||||
    form.append('file', fs.createReadStream(path.join(cwd(), "/tmp/torrent/" + info.seedName.replace(" ",".") + ".torrent")))
 | 
			
		||||
    form.append("name", info.title.replace("Epxxx", "E" + info.ep))
 | 
			
		||||
    let ep = await getDownEp(info.vid)
 | 
			
		||||
    if(ep.start == ep.end){
 | 
			
		||||
        form.append("name", info.title.replace("Epxxx", "E" + info.ep))
 | 
			
		||||
    }else{
 | 
			
		||||
        form.append("name", info.title.replace("Epxxx", "E" + ep.start + "-" + "E" + ep.end))
 | 
			
		||||
    }
 | 
			
		||||
    form.append("small_descr", vinfo.subtitle)
 | 
			
		||||
    form.append("url", vinfo.imdb)
 | 
			
		||||
    form.append("descr", desc)
 | 
			
		||||
    form.append("type", vinfo.type)
 | 
			
		||||
    form.append("pt_gen", 'https://movie.douban.com/subject/' + vinfo.vid + "/")
 | 
			
		||||
    let tags = vinfo.tags.split(",")
 | 
			
		||||
    for (let i of tags) {
 | 
			
		||||
        form.append("tags[4][]", i)
 | 
			
		||||
 | 
			
		||||
@ -44,9 +44,50 @@ async function getMediaState(vid){
 | 
			
		||||
    // return true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 获取下载的ep开始与结束
 | 
			
		||||
 * @param {string} vid 视频vid
 | 
			
		||||
 * @returns {{start:string,end:string}} start开始集数,end结束集数
 | 
			
		||||
 */
 | 
			
		||||
async function getDownEp(vid){
 | 
			
		||||
    let sql = `select * from download where vid=? and state!=2`
 | 
			
		||||
    let list = await getAll(sql,vid)
 | 
			
		||||
    if(list.length == 0){
 | 
			
		||||
        let sql = `select * from download where vid=? and state=1`
 | 
			
		||||
        let list = await getAll(sql,vid)
 | 
			
		||||
        let ep = []
 | 
			
		||||
        for(let i of list){
 | 
			
		||||
            ep.push(parseInt(i.title))
 | 
			
		||||
        }
 | 
			
		||||
        ep.sort((a,b)=>{
 | 
			
		||||
            return a - b
 | 
			
		||||
        })
 | 
			
		||||
        return {
 | 
			
		||||
            start: ep[0],
 | 
			
		||||
            end:ep[ep.length - 1]
 | 
			
		||||
        }
 | 
			
		||||
    }else{
 | 
			
		||||
        return false
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 通过vid设置下载状态
 | 
			
		||||
 * @param {string} vid 视频vid
 | 
			
		||||
 * @param {number} state 状态
 | 
			
		||||
 */
 | 
			
		||||
async function setDownStateVid(vid,state){
 | 
			
		||||
    let sql = `update download set state = ? where vid = ?`
 | 
			
		||||
    await run(sql,state,vid)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
    addDownList,
 | 
			
		||||
    getDownList,
 | 
			
		||||
    setDownState,
 | 
			
		||||
    getMediaState
 | 
			
		||||
    getMediaState,
 | 
			
		||||
    getDownEp,
 | 
			
		||||
    setDownStateVid
 | 
			
		||||
}
 | 
			
		||||
@ -42,6 +42,7 @@ async function getVideoInfo(sid){
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
    addSub,
 | 
			
		||||
    getSub,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user