add 发种与下载种子 移动到做种文件夹
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
const path = require('path')
|
||||
const {dow, fileIsExist,getMediaInfo} = require("../utils.js");
|
||||
const { dow, fileIsExist, getMediaInfo } = require("../utils.js");
|
||||
const { mkdirRecursions } = require('../markdir.js');
|
||||
const schedule = require('node-schedule');
|
||||
const { setDownState, getDownList } = require('../sql/download.js');
|
||||
@@ -8,107 +8,109 @@ const fs = require("fs");
|
||||
const { sendSeed } = require('../SendSeed/index.js');
|
||||
|
||||
// 小于10添加0
|
||||
function addZeor(num){
|
||||
if(num < 10){
|
||||
function addZeor(num) {
|
||||
if (num < 10) {
|
||||
return "0" + num
|
||||
}else{
|
||||
} else {
|
||||
return num
|
||||
}
|
||||
}
|
||||
|
||||
// 重命名
|
||||
async function reName(dinfo){
|
||||
async function reName(dinfo) {
|
||||
let vinfo = await getVideoInfo(dinfo.vid)
|
||||
console.log(vinfo)
|
||||
if(vinfo){
|
||||
if (vinfo) {
|
||||
let info = await getMediaInfo(dinfo.save + "/" + dinfo.title + ".mp4")
|
||||
console.log(info,dinfo.save + "/" + dinfo.title + ".mp4")
|
||||
console.log(info, dinfo.save + "/" + dinfo.title + ".mp4")
|
||||
info = info.media.track
|
||||
let Video;
|
||||
let Audio;
|
||||
for(let i of info){
|
||||
if(i["@type"] == "Video"){
|
||||
for (let i of info) {
|
||||
if (i["@type"] == "Video") {
|
||||
Video = i
|
||||
}
|
||||
if(i["@type"] == "Audio"){
|
||||
if (i["@type"] == "Audio") {
|
||||
Audio = i
|
||||
break
|
||||
}
|
||||
}
|
||||
// 判断时长 0 为下载 1 下载完成 2 做种 3 没有下载完成或没有会员
|
||||
if(Video.Duration < 4 * 60){
|
||||
if (Video.Duration < 4 * 60) {
|
||||
return {
|
||||
state: 3
|
||||
}
|
||||
}
|
||||
let fbl = 0
|
||||
if(Video.Height > 3000){
|
||||
if (Video.Height > 3000) {
|
||||
fbl = 4320
|
||||
}else if(Video.Height > 1440){
|
||||
} else if (Video.Height > 1440) {
|
||||
fbl = 2160
|
||||
}else if(Video.Height > 1080){
|
||||
} else if (Video.Height > 1080) {
|
||||
fbl = 1440
|
||||
}else if(Video.Height > 720){
|
||||
} else if (Video.Height > 720) {
|
||||
fbl = 1080
|
||||
}else if(Video.Height > 480){
|
||||
} else if (Video.Height > 480) {
|
||||
fbl = 720
|
||||
}else {
|
||||
} else {
|
||||
fbl = 480
|
||||
}
|
||||
let rname = `[${vinfo.name}].${vinfo.rename}.${vinfo.year}.S${addZeor(vinfo.season)}E${addZeor(dinfo.title)}.WEB-DL.${fbl}p.${Video.Format}.${Audio.Format}@ZmWeb.mp4`
|
||||
let state = fs.renameSync(dinfo.save + "/" + dinfo.title + ".mp4",dinfo.save + "/" + rname)
|
||||
let rname = `${vinfo.name}.${vinfo.rename}.${vinfo.year}.S${addZeor(vinfo.season)}E${addZeor(dinfo.title)}.WEB-DL.${fbl}p.${Video.Format}.${Audio.Format}@ZmWeb.mp4`
|
||||
let state = fs.renameSync(dinfo.save + "/" + dinfo.title + ".mp4", dinfo.save + "/" + rname)
|
||||
let newPath = ""
|
||||
let tem = dinfo.save.split("/")
|
||||
let tem = dinfo.save.split("/")
|
||||
tem.pop()
|
||||
let seedName = `[${vinfo.name}].${vinfo.rename}.${vinfo.year}.S${addZeor(vinfo.season)}.WEB-DL.${fbl}p.${Video.Format}.${Audio.Format}@ZmWeb`
|
||||
let seedName = `${vinfo.name}.${vinfo.rename}.${vinfo.year}.S${addZeor(vinfo.season)}.WEB-DL.${fbl}p.${Video.Format}.${Audio.Format}@ZmWeb`
|
||||
tem.push(seedName)
|
||||
newPath = tem.join("/")
|
||||
return {
|
||||
state: 1,
|
||||
info:{
|
||||
info: {
|
||||
vid: dinfo.vid,
|
||||
oldPath: dinfo.save,
|
||||
newPath: newPath,
|
||||
seedName,
|
||||
title: `${vinfo.rename} ${vinfo.year} S${addZeor(vinfo.season)}Epxxx WEB-DL ${fbl}p ${Video.Format} ${Audio.Format}@ZmWeb`,
|
||||
Duration: Video.Duration,
|
||||
rname
|
||||
rname,
|
||||
ep: addZeor(dinfo.title),
|
||||
fbl
|
||||
}
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
console.log("未找到当前剧集信息")
|
||||
return{
|
||||
return {
|
||||
state: 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 当前下载状态
|
||||
let state = false
|
||||
async function CheckDown(){
|
||||
if(state){
|
||||
async function CheckDown() {
|
||||
if (state) {
|
||||
return
|
||||
}
|
||||
let list = await getDownList()
|
||||
if(list.length > 0){
|
||||
if (list.length > 0) {
|
||||
state = true
|
||||
let dinfo = list[0]
|
||||
mkdirRecursions(dinfo.save)
|
||||
dow(dinfo,async (msg,s)=>{
|
||||
dow(dinfo, async (msg, s) => {
|
||||
console.log(String(msg))
|
||||
if(s){
|
||||
if (s) {
|
||||
let exist = fileIsExist(dinfo.save + "/" + dinfo.title + ".mp4")
|
||||
if(exist){
|
||||
if (exist) {
|
||||
// 设置状态
|
||||
let s = await reName(dinfo)
|
||||
await setDownState(dinfo.id,s.state)
|
||||
await setDownState(dinfo.id, s.state)
|
||||
state = false
|
||||
if(s.info){
|
||||
if (s.info) {
|
||||
sendSeed(s.info)
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
// 重新下载
|
||||
console.log("下载失败重新下载")
|
||||
state = false
|
||||
|
||||
Reference in New Issue
Block a user