add 种子制作

This commit is contained in:
theluyuan 2023-07-23 01:03:29 +08:00
parent 539131dcec
commit 761c6eabe8
12 changed files with 87 additions and 17 deletions

Binary file not shown.

BIN
tmp/imgs/1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

BIN
tmp/imgs/2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

BIN
tmp/imgs/3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB

View File

@ -4,7 +4,8 @@ const { mkdirRecursions } = require('../markdir.js');
const schedule = require('node-schedule');
const { setDownState, getDownList } = require('../sql/download.js');
const { getVideoInfo } = require('../sql/video.js');
const fs = require("fs")
const fs = require("fs");
const { sendSeed } = require('../SendSeed/index.js');
// 小于10添加0
function addZeor(num){
@ -36,7 +37,9 @@ async function reName(dinfo){
}
// 判断时长 0 为下载 1 下载完成 2 做种 3 没有下载完成或没有会员
if(Video.Duration < 4 * 60){
return 3
return {
state: 3
}
}
let fbl = 0
if(Video.Height > 3000){
@ -52,13 +55,33 @@ async function reName(dinfo){
}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}.mp4`
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("/")
tem.pop()
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:{
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
}
}
}else{
console.log("未找到当前剧集信息")
return{
state: 0
}
}
return 1
}
@ -80,9 +103,11 @@ async function CheckDown(){
if(exist){
// 设置状态
let s = await reName(dinfo)
await setDownState(dinfo.id,1)
await setDownState(dinfo.id,s.state)
state = false
if(s.info){
sendSeed(s.info)
}
}else{
// 重新下载
console.log("下载失败重新下载")

35
util/SendSeed/index.js Normal file
View File

@ -0,0 +1,35 @@
const fs = require("fs")
const { getMediaState } = require("../sql/download.js");
const path = require("path");
const { cwd } = require("process");
const { createTorrent, getVideoSpecifyTimeImage } = require("../utils.js");
async function updateSeed(){
}
async function sendSeed(info){
console.log(info)
let state = await getMediaState(info.vid)
console.log(state)
if(state){
// 重命名文件夹
fs.renameSync(info.oldPath, info.newPath);
// 创建种子
await createTorrent(info.newPath,path.join(cwd(),"/tmp/torrent/" + info.seedName + ".torrent"))
// 获取图片
for(let i = 1; i < 4; i++){
let time = info.Duration
time = Math.floor(time / 4)
await getVideoSpecifyTimeImage(info.newPath + "/" + info.rname,time * i,path.join(cwd(),"/tmp/imgs/" + i + ".jpg"))
}
await updateSeed(info.vid,)
}else{
console.log("未下载完成")
}
}
module.exports = {
sendSeed
}

View File

@ -35,8 +35,16 @@ async function addVideoInfo(cover){
}
// 获取当前剧集是否下载完成
async function getMediaState(vid){
let sql = `select * from download where vid=? and state!=1`
let list = await getAll(sql,vid)
return !list.length
}
module.exports = {
addDownList,
getDownList,
setDownState
setDownState,
getMediaState
}

View File

@ -8,8 +8,8 @@ async function addSub(info){
if(list.length != 0){
return "订阅已存在"
}
let sql = `insert into VideoInfo(name,rename,skip,desc,url,subtitle,img,year,time,subTime,enable,season,sid,count) values(?,?,?,?,?,?,?,?,?,${new Date().getTime()},1,?,?,?)`
await run(sql,info.name,info.rename,info.skip,info.desc,info.url,info.subtitle,info.img,info.year,info.time,info.season,info.sid,info.count)
let sql = `insert into VideoInfo(name,rename,skip,desc,url,subtitle,img,year,time,subTime,enable,season,sid,count,imdb) values(?,?,?,?,?,?,?,?,?,${new Date().getTime()},1,?,?,?,?)`
await run(sql,info.name,info.rename,info.skip,info.desc,info.url,info.subtitle,info.img,info.year,info.time,info.season,info.sid,info.count,info.imdb)
}
// 获取所有订阅 (不包括已完成)

View File

@ -174,15 +174,15 @@ function formatSeconds(value) {
minuteTime = parseInt(minuteTime % 60);
}
}
var result = "" + secondTime > 10 ? secondTime : '0' + secondTime;
var result = "" + secondTime >= 10 ? secondTime : '0' + secondTime;
if (minuteTime > 0) {
result = "" + minuteTime > 10 ? minuteTime : '0' + minuteTime + ":" + result;
result = "" + (minuteTime >= 10 ? minuteTime : '0' + minuteTime) + ":" + result;
} else {
result = "" + "00" + ":" + result;
}
if (hourTime > 0) {
result = "" + hourTime > 10 ? hourTime : '0' + hourTime + ":" + result;
result = "" + (hourTime >= 10 ? hourTime : '0' + hourTime) + ":" + result;
} else {
result = "" + "00" + ":" + result;
}

View File

@ -24,8 +24,8 @@ export async function getImdbName(url) {
}
})
}
export async function addSubscribe({name, rename, desc, year, season, ep, url, img, subtitle, time,skip,sid,count}) {
return await base.post("/videoInfo/addSubscribe", {name, rename, desc, year, season, ep, url, img, subtitle, time,skip,sid,count})
export async function addSubscribe({name, rename, desc, year, season, ep, url, img, subtitle, time,skip,sid,count,imdb}) {
return await base.post("/videoInfo/addSubscribe", {name, rename, desc, year, season, ep, url, img, subtitle, time,skip,sid,count,imdb})
}
export async function getSubscribe(){

View File

@ -99,7 +99,7 @@ onBeforeRouteUpdate(next => {
let vid = "";
const dialogFormVisible = ref(false)
let imdb = "";
async function getInfo(id, i) {
const loadingInstance = ElLoading.service({fullscreen: true})
@ -108,6 +108,7 @@ async function getInfo(id, i) {
let res = await getVideoInfo(id)
info.value = res.data.format
year.value = res.data.year
imdb = res.data.imdb_link || ""
console.info(res.data.trans_title.length)
if (res.data.trans_title.length === 0) {
subtitle.value = res.data.this_title.join(" / ")
@ -147,7 +148,8 @@ async function addsubscribe() {
time: dayjs(time.value).format("HH:mm:ss"),
skip: season.value,
sid: vid,
count: count.value
count: count.value,
imdb: imdb
}
for (let i in data) {
if (!data[i]) {