diff --git a/README.MD b/README.MD index 2e0bfad..7df4584 100644 --- a/README.MD +++ b/README.MD @@ -13,13 +13,13 @@ mtvdownload can extract video links in bulk from HTML files or websites and then windows ```shell -./mtvdownloader.exe -d "./download/Top Female Groups" -i "./YouTube - Most Viewed Music Videos by Female Groups.html" +./mtvdownloader.exe -d "./download/Top Female Groups" -i "https://kworb.net/youtube/topvideos_female_group.html" ``` node ```shell -node ./dist/bundle.cjs -d "./download/Top Female Groups" -i "./YouTube - Most Viewed Music Videos by Female Groups.html" +node ./dist/bundle.cjs -d "./download/Top Female Groups" -i "https://kworb.net/youtube/topvideos_female_group.html" ``` ![Most Viewed Music Videos by Female Groups](<./screenshots/YouTube - Most Viewed Music Videos by Female Groups.png>) diff --git a/README_CN.MD b/README_CN.MD index 88c5925..4e72035 100644 --- a/README_CN.MD +++ b/README_CN.MD @@ -12,13 +12,13 @@ mtvdownload 可以从 HTML 文件或网站中批量提取视频链接,然后 windows ```shell -./mtvdownloader.exe -d "./download/Top Female Groups" -i "./YouTube - Most Viewed Music Videos by Female Groups.html" +./mtvdownloader.exe -d "./download/Top Female Groups" -i "https://kworb.net/youtube/topvideos_female_group.html" ``` node ```shell -node ./dist/bundle.cjs -d "./download/Top Female Groups" -i "./YouTube - Most Viewed Music Videos by Female Groups.html" +node ./dist/bundle.cjs -d "./download/Top Female Groups" -i "https://kworb.net/youtube/topvideos_female_group.html" ``` ![观看最多的女团视频](<./screenshots/YouTube - Most Viewed Music Videos by Female Groups.png>) diff --git a/src/downloader.ts b/src/downloader.ts index c419416..7f88fbb 100644 --- a/src/downloader.ts +++ b/src/downloader.ts @@ -15,8 +15,9 @@ const downloader = { ): Promise => { let title = options.name; const url = `https://www.youtube.com/watch?v=${id}`; + console.log(`id(${id}),url(${url}),fetching...`); const info = await ytdl.getInfo(url); - console.info(`id(${id}),url(${url}),title(${info.videoDetails.title})`); + console.info(`id(${id}),title(${info.videoDetails.title})`); let videoFormat: ytdl.videoFormat | undefined; if (options.videoFormat) videoFormat = options.videoFormat(info.formats.filter((x) => x.hasVideo)); if (!title) title = info.videoDetails.title; @@ -42,8 +43,12 @@ const downloader = { } }; clearDownload(); - if (fs.existsSync(targetFile)) return targetFile; return new Promise((resolve, reject) => { + if (fs.existsSync(targetFile)) { + resolve(targetFile); + return; + } + console.log(`download(${tmpFile}) starting...`); let progressbarHandle = null; let updateBy = Date.now(); const checkTimeout = () => { diff --git a/src/index.ts b/src/index.ts index d3fc45d..6b8cb04 100644 --- a/src/index.ts +++ b/src/index.ts @@ -67,12 +67,8 @@ const download = async (key: string) => { console.log(`Video(${key}) unavailable,skip and continue next.`); else if ((err as Error).message.includes('Status code: 410')) console.log(`Video(${key}) code 410,skip and continue next.`); - else if ( - (err as Error).message.includes( - 'This is a private video. Please sign in to verify that you may see it,skip and continue next.' - ) - ) - console.log(`Video(${key}) private.`); + else if ((err as Error).message.includes('This is a private video. Please sign in to verify that you may see it.')) + console.log(`Video(${key}) private,skip and continue next.`); else if ((err as Error).message.includes('write EPIPE')) { console.log(`Video(${key}) write EPIPE,retrying...`); await sleep(10 * 1000);