fix 获取ep

This commit is contained in:
theluyuan 2023-08-08 20:47:46 +08:00
parent 007c76ccd3
commit 01308db3cf
3 changed files with 6 additions and 4 deletions

View File

@ -20,7 +20,7 @@ app.use(async (ctx, next) => {
const index = require("./router/index.js") const index = require("./router/index.js")
app.use(index.routes()).use(index.allowedMethods()) app.use(index.routes()).use(index.allowedMethods())
const videoInfo = require("./router/videoInfo.js"); const videoInfo = require("./router/videoInfo.js");
const config = require("./router/config.js") const config = require("./router/config.js");
app.use(config.routes()).use(config.allowedMethods()) app.use(config.routes()).use(config.allowedMethods())
app.use(videoInfo.routes()).use(videoInfo.allowedMethods()) app.use(videoInfo.routes()).use(videoInfo.allowedMethods())
@ -28,4 +28,3 @@ app.listen(3050, "0.0.0.0");
// 引入定时检测更新 // 引入定时检测更新
require("./util/Video/Update.js") require("./util/Video/Update.js")
console.log("link: http://127.0.0.1:3050")

View File

@ -1,5 +1,5 @@
const fs = require("fs") const fs = require("fs")
const { getMediaState, getDownEp } = require("../sql/download.js"); const { getMediaState, getDownEp, setDownStateVid } = require("../sql/download.js");
const path = require("path"); const path = require("path");
const { cwd } = require("process"); const { cwd } = require("process");
const { createTorrent, getVideoSpecifyTimeImage, uploadImg, getMediaInfoSend, deleteFolder, moveDir } = require("../utils.js"); const { createTorrent, getVideoSpecifyTimeImage, uploadImg, getMediaInfoSend, deleteFolder, moveDir } = require("../utils.js");
@ -17,11 +17,13 @@ async function updateSeed(info, desc) {
let form = new FormData() let form = new FormData()
form.append('file', fs.createReadStream(path.join(cwd(), "/tmp/torrent/" + info.seedName.replace(" ",".") + ".torrent"))) form.append('file', fs.createReadStream(path.join(cwd(), "/tmp/torrent/" + info.seedName.replace(" ",".") + ".torrent")))
let ep = await getDownEp(info.vid) let ep = await getDownEp(info.vid)
console.log(ep)
if(ep.start == ep.end){ if(ep.start == ep.end){
form.append("name", info.title.replace("Epxxx", "E" + info.ep)) form.append("name", info.title.replace("Epxxx", "E" + info.ep))
}else{ }else{
form.append("name", info.title.replace("Epxxx", "E" + ep.start + "-" + "E" + ep.end)) form.append("name", info.title.replace("Epxxx", "E" + ep.start + "-" + "E" + ep.end))
} }
await setDownStateVid(info.vid,2)
form.append("small_descr", vinfo.subtitle) form.append("small_descr", vinfo.subtitle)
form.append("url", vinfo.imdb) form.append("url", vinfo.imdb)
form.append("descr", desc) form.append("descr", desc)

View File

@ -51,8 +51,9 @@ async function getMediaState(vid){
* @returns {{start:string,end:string}} start开始集数end结束集数 * @returns {{start:string,end:string}} start开始集数end结束集数
*/ */
async function getDownEp(vid){ async function getDownEp(vid){
let sql = `select * from download where vid=? and state!=2` let sql = `select * from download where vid=? and (state=3 OR state=0)`
let list = await getAll(sql,vid) let list = await getAll(sql,vid)
console.log(vid,list)
if(list.length == 0){ if(list.length == 0){
let sql = `select * from download where vid=? and state=1` let sql = `select * from download where vid=? and state=1`
let list = await getAll(sql,vid) let list = await getAll(sql,vid)