diff --git a/util/Download/index.js b/util/Download/index.js index 3792c11..a2a7fe9 100644 --- a/util/Download/index.js +++ b/util/Download/index.js @@ -87,6 +87,32 @@ async function reName(dinfo) { } +function dowv(dinfo){ + return new Promise((res)=>{ + dow(dinfo, async (msg, s) => { + console.log(String(msg)) + if (s) { + let exist = fileIsExist(dinfo.save + "/" + dinfo.title + ".mp4") + if (exist) { + // 设置状态 + let s = await reName(dinfo) + await setDownState(dinfo.id, s.state) + state = false + if (s.info) { + await sendSeed(s.info) + } + res(s) + } else { + // 重新下载 + console.log("下载失败重新下载") + state = false + } + } + }) + }) + +} + // 当前下载状态 let state = false async function CheckDown() { @@ -98,25 +124,7 @@ async function CheckDown() { state = true let dinfo = list[0] mkdirRecursions(dinfo.save) - dow(dinfo, async (msg, s) => { - console.log(String(msg)) - if (s) { - let exist = fileIsExist(dinfo.save + "/" + dinfo.title + ".mp4") - if (exist) { - // 设置状态 - let s = await reName(dinfo) - await setDownState(dinfo.id, s.state) - state = false - if (s.info) { - sendSeed(s.info) - } - } else { - // 重新下载 - console.log("下载失败重新下载") - state = false - } - } - }) + await dowv(dinfo) } }