Closed lkareeml closed 4 years ago
might be a dupe of https://github.com/fent/node-ytdl-core/issues/212
Note : It doesn't matter which video in the array, because when I re Run The Code It starts Downloading again normally
does the error happen on the same video in the array each time? if so, what's the video?
unable to reproduce, but since i'm already here:
a) you can skip that yotub
variable and just pass the id to ytdl, should even improve performance
b) you should change if (i < arr.length)
to if (i <= arr.length)
c) your global variable let i = 0
only gets used for the first doit(i)
call, the int gets passed by value (not reference like you wrote in your comment) and i = i + 1;
only updates the local version - means your global i
will forever stay 0
and you could just use doit(0)
the first time and doit(i+1)
later on
might be a dupe of #212
Note : It doesn't matter which video in the array, because when I re Run The Code It starts Downloading again normally
does the error happen on the same video in the array each time? if so, what's the video?
for the error #212 I read it and no information was clarified with the issue
no, It doesn't happen in the same video, I downloaded the full series just by this script, only when it repeats many times it just happens
unable to reproduce, but since i'm already here: a) you can skip that
yotub
variable and just pass the id to ytdl, should even improve performance
That's right and I didn't realize that it will improve performance, Thank you
b) you should change
if (i < arr.length)
toif (i <= arr.length)
To cover the full array! Thank you again!
c) your global variable
let i = 0
only gets used for the firstdoit(i)
call, the int gets passed by value (not reference like you wrote in your comment) andi = i + 1;
only updates the local version - means your globali
will forever stay0
and you could just usedoit(0)
the first time anddoit(i+1)
later on
This is really a new information to me, it was really a stupid from me to do a global variable
I Really Appreciate your tips, Thank you so much for tips and advice, I will do so in further projects for the code error to be produced This is the full code
const readline = require('readline');
const fs = require('fs');
const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path;
const ffmpeg = require('fluent-ffmpeg');
ffmpeg.setFfmpegPath(ffmpegPath);
const ytdl = require( 'ytdl-core');
const vidFHOption = {filter:"videoonly",quality:"highestvideo"};
const audFHOption = {filter:"audioonly",quality:"highestaudio"};
const arr = [
"mZXwg1t8jq8","rLKMoaqBX-0","a8AGreEQ2Cc","vLpjzCGjces",
"Bh7YKvLBZ4U","n7Vv7r7zS-c","EnkRJ5JSMN0","l5eQLAKq7Qg",
"Qhio7I8L6bs","1wd6bcoYaNk","_QIjU1KCjuU","nfOe_g5va2U",
"E3Mb5EccHqM","qva0bWuKtwQ","q7vJYSWJ7Pc","TH2ezcduskk",
"rK5sEP0ZFUE","XxI4VwewmPg","JB8d39D71Gs","HkupQXkx8hk",
"o-vgQFtjBZQ","6SbgmNVrdM8","eIcOujrFyII","06GNCzKWF3M",
"rYjJz177bb0","mtcmYQ4rUYM","wy_0sj56lPI","5yZ6pUCneWs",
"3fnnpKHhld8","UswF0NTZbPM","PvxK95bp74M","JRFnDMUHdrw",
"cvmfkuuslQs","KC-mhZz7n6o","RVTEHWUts2w","1pt6lAeuzFI",
"Ve7e94SM8mo","glKnCp5hl-A","5j1stlT9Mp0","DuSJmGiP1sA",
"67MLCmZ_pOc","VDhKqt0Sx58","qz_xALU-xtw","zPfykU9mm8A",
"pXZo0gcrQvs","XQWaXmVwaIg"
]
function doit(i) {
console.log("START Downloading Episode " + i + "\n");
ytdl("https://www.youtube.com/watch?v=" + arr[i], vidFHOption).on('progress', (chunkLength, downloaded, total) => {
const percent = downloaded / total;
readline.cursorTo(process.stdout, 0);
process.stdout.write(`${(percent * 100).toFixed(2)}% downloaded `);
process.stdout.write(`(${(downloaded / 1024 / 1024).toFixed(2)}MB of ${(total / 1024 / 1024).toFixed(2)}MB)`);
}).pipe(fs.createWriteStream('EP' + i + '.m4v')).on('finish', () => {
ytdl("https://www.youtube.com/watch?v=" + arr[i], audFHOption).on('progress', (chunkLength, downloaded, total) => {
const percent = downloaded / total;
readline.cursorTo(process.stdout, 0);
process.stdout.write(`${(percent * 100).toFixed(2)}% downloaded `);
process.stdout.write(`(${(downloaded / 1024 / 1024).toFixed(2)}MB of ${(total / 1024 / 1024).toFixed(2)}MB)`);
}).pipe(fs.createWriteStream('EP' + i + '.m4a')).on('finish', () => {
console.log("\n Downloading Episode " + i + " is DONE!!");
if (i <= arr.length)
doit(i + 1);
});
});
}
doit(0);
ran into the same problem, looks like some generic network problems to me; just retrying the download always fixed it (at least on my machine)
going to mark this as a dupe of https://github.com/fent/node-ytdl-core/issues/212 to keep things organized
When using ytdl inside a function and trying to do recursion and download an array of videos It works fine for some amount of videos and then it throw error Note : It doesn't matter which video in the array, because when I re Run The Code It starts Downloading again normally
A Code example :
Code Notes: For Video1 , Video2 you can write YouTube video text , The text after "?v=" for example "C0DPdy98e4c" Where (yotub + arr[i]) == the full YouTube link
For me the error came after 31 videos, after Running again it came after 10 videos
The Error :
Hope I documented it well first issue to write lol