Skip to content

Commit

Permalink
update.
Browse files Browse the repository at this point in the history
  • Loading branch information
topabomb committed Sep 6, 2023
1 parent 8b8bc83 commit d2b790d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -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>)
Expand Down
4 changes: 2 additions & 2 deletions README_CN.MD
Original file line number Diff line number Diff line change
Expand Up @@ -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>)
Expand Down
9 changes: 7 additions & 2 deletions src/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ const downloader = {
): Promise<string> => {
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;
Expand All @@ -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 = () => {
Expand Down
8 changes: 2 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d2b790d

Please sign in to comment.