add 移动多文件
This commit is contained in:
parent
4bc2504a44
commit
b675e3033d
@ -1,5 +1,5 @@
|
|||||||
const Router = require("koa-router")
|
const Router = require("koa-router")
|
||||||
const {search, gen_douban} = require("../util/ptgen")
|
const {serach, gen_douban} = require("../util/ptgen")
|
||||||
const axios = require("axios")
|
const axios = require("axios")
|
||||||
const cheerio = require("cheerio");
|
const cheerio = require("cheerio");
|
||||||
const {addSub, getSub, delSub} = require("../util/sql/video"); // HTML页面解析
|
const {addSub, getSub, delSub} = require("../util/sql/video"); // HTML页面解析
|
||||||
@ -13,7 +13,7 @@ const router = new Router({
|
|||||||
*/
|
*/
|
||||||
router.get("/searchVideo", async (ctx) => {
|
router.get("/searchVideo", async (ctx) => {
|
||||||
let name = ctx.query.name
|
let name = ctx.query.name
|
||||||
ctx.body = await search(name)
|
ctx.body = await serach(name)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ const fs = require("fs")
|
|||||||
const { getMediaState } = require("../sql/download.js");
|
const { getMediaState } = 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 } = require("../utils.js");
|
const { createTorrent, getVideoSpecifyTimeImage, uploadImg, getMediaInfoSend, deleteFolder, moveDir } = require("../utils.js");
|
||||||
const { getVideoInfo } = require("../sql/video.js");
|
const { getVideoInfo } = require("../sql/video.js");
|
||||||
const { mkdirRecursions } = require("../markdir.js");
|
const { mkdirRecursions } = require("../markdir.js");
|
||||||
const { default: axios } = require("axios");
|
const { default: axios } = require("axios");
|
||||||
@ -106,11 +106,10 @@ async function sendSeed(info) {
|
|||||||
}
|
}
|
||||||
// 移动到做种文件夹
|
// 移动到做种文件夹
|
||||||
mkdirRecursions(newDir + "/" + info.seedName + "/")
|
mkdirRecursions(newDir + "/" + info.seedName + "/")
|
||||||
fs.renameSync(info.newPath + "/" + info.rname, newDir + "/" + info.seedName + "/" + info.rname);
|
// fs.renameSync(info.newPath + "/" + info.rname, newDir + "/" + info.seedName + "/" + info.rname);
|
||||||
|
moveDir(info.newPath + "/" ,newDir + "/" + info.seedName + "/")
|
||||||
// 删除下载的文件夹
|
// 删除下载的文件夹
|
||||||
deleteFolder(info.newPath)
|
deleteFolder(info.newPath)
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
console.log("未下载完成")
|
console.log("未下载完成")
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const axios = require("axios")
|
const axios = require("axios")
|
||||||
const cheerio = require("cheerio"); // HTML页面解析
|
const cheerio = require("cheerio"); // HTML页面解析
|
||||||
async function search(name) {
|
async function serach(name) {
|
||||||
const list = await axios.get(`https://movie.douban.com/j/subject_suggest?q=${name}`, {
|
const list = await axios.get(`https://movie.douban.com/j/subject_suggest?q=${name}`, {
|
||||||
proxy: false,
|
proxy: false,
|
||||||
})
|
})
|
||||||
@ -212,6 +212,6 @@ async function gen_douban(sid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
serach: search,
|
serach,
|
||||||
gen_douban
|
gen_douban
|
||||||
}
|
}
|
@ -38,10 +38,10 @@ async function addVideoInfo(cover){
|
|||||||
// 获取当前剧集是否下载完成
|
// 获取当前剧集是否下载完成
|
||||||
// todo 多集连发
|
// todo 多集连发
|
||||||
async function getMediaState(vid){
|
async function getMediaState(vid){
|
||||||
// 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)
|
||||||
// return !list.length
|
return !list.length
|
||||||
return true
|
// return true
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -246,6 +246,31 @@ function deleteFolder(filePath) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移动文件夹下的所有文件(不包括文件夹)
|
||||||
|
* @param {string} sourceFolder 源文件夹
|
||||||
|
* @param {string} targetFolder 目标文件夹
|
||||||
|
*/
|
||||||
|
function moveDir(sourceFolder,targetFolder ){
|
||||||
|
try {
|
||||||
|
// 读取源文件夹中的所有文件
|
||||||
|
const files = fs.readdirSync(sourceFolder);
|
||||||
|
|
||||||
|
// 遍历源文件夹中的文件
|
||||||
|
files.forEach(file => {
|
||||||
|
// 构建源文件和目标文件的完整路径
|
||||||
|
const sourcePath = path.join(sourceFolder, file);
|
||||||
|
const targetPath = path.join(targetFolder, file);
|
||||||
|
|
||||||
|
// 移动文件
|
||||||
|
fs.renameSync(sourcePath, targetPath);
|
||||||
|
console.log(`成功移动文件 ${file}`);
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error('无法读取源文件夹或移动文件:', err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
seep,
|
seep,
|
||||||
@ -258,5 +283,6 @@ module.exports = {
|
|||||||
spawn,
|
spawn,
|
||||||
fileIsExist,
|
fileIsExist,
|
||||||
getMediaInfoSend,
|
getMediaInfoSend,
|
||||||
deleteFolder
|
deleteFolder,
|
||||||
|
moveDir
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user