node-ytdl-core icon indicating copy to clipboard operation
node-ytdl-core copied to clipboard

YTDL-core downloads blank files, with no data

Open MalikElate opened this issue 1 year ago • 11 comments

Hey, I'm trying to use ytdl-core but its stopped working across several version. When I download a video I get a blank file that is zero bytes. I'm expecting that videos should download as normal.

I'm running the most basic download but it work work. `const fs = require('fs'); const ytdl = require('ytdl-core');

ytdl('http://www.youtube.com/watch?v=aqz-KE-bpKQ') .pipe(fs.createWriteStream('video.mp4'));`

Screenshot 2024-07-18 at 4 57 53 PM

Any help on this would be greatly appreciated

MalikElate avatar Jul 18 '24 21:07 MalikElate

The same thing happened to me today, from what i read in other recent issues it seems to be related to some changes made by Youtube, maybe made to stop this kind of libraries from working. hope it gets solved soon.

EnzoDev10 avatar Jul 19 '24 19:07 EnzoDev10

The same thing happened to me today, from what i read in other recent issues it seems to be related to some changes made by Youtube, maybe made to stop this kind of libraries from working. hope it gets solved soon.

Im not sure, did also notice other libraries were affect.

I was able to restart my computer (mac) and it working normally now

MalikElate avatar Jul 19 '24 20:07 MalikElate

good to know that it works for you, i tried restarting mine(windows) and it still doesn't work.

EnzoDev10 avatar Jul 19 '24 21:07 EnzoDev10

try out https://www.npmjs.com/package/youtube-dl-exec

until a fix it pushed

const download = await ytdl.exec(link, { x: true });'

Or see this https://github.com/fent/node-ytdl-core/issues/1299

phyzical avatar Jul 20 '24 13:07 phyzical

I noticed the fix in yt-dlp from today: https://github.com/yt-dlp/yt-dlp/commit/f0993391e6052ec8f7aacc286609564f226943b9

It is quite substantial, though. Needs porting.

corwin-of-amber avatar Jul 25 '24 14:07 corwin-of-amber

try out https://www.npmjs.com/package/youtube-dl-exec

I tried using the link referenced, and copy-pasted the first code under the usage section const youtubedl = require('youtube-dl-exec')... and it gives this error. since im new i have no idea whats going on but any support would be greatly appreciated.

\Desktop\VSCode Projects\Serious Projects\YouTube-To-MP4\node_modules\ytdl-core\lib\format-utils.js:226
  return formats.filter(format => !!format.url && fn(format));
                                                  ^

TypeError: Array.prototype.filter called on null or undefined
    at filter (<anonymous>)
    at C:\Users\datha\Desktop\Desktop\VSCode Projects\Serious Projects\YouTube-To-MP4\node_modules\ytdl-core\lib\format-utils.js:226:51
    at Array.filter (<anonymous>)
    at exports.filterFormats (C:\Users\datha\Desktop\Desktop\VSCode Projects\Serious Projects\YouTube-To-MP4\node_modules\ytdl-core\lib\format-utils.js:226:18)
    at exports.chooseFormat (C:\Users\datha\Desktop\Desktop\VSCode Projects\Serious Projects\YouTube-To-MP4\node_modules\ytdl-core\lib\format-utils.js:104:23)
    at downloadFromInfoCallback (C:\Users\datha\Desktop\Desktop\VSCode Projects\Serious Projects\YouTube-To-MP4\node_modules\ytdl-core\lib\index.js:86:26)
    at C:\Users\datha\Desktop\Desktop\VSCode Projects\Serious Projects\YouTube-To-MP4\node_modules\ytdl-core\lib\index.js:20:5
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Emitted 'error' event on PassThrough instance at:
    at downloadFromInfoCallback (C:\Users\datha\Desktop\Desktop\VSCode Projects\Serious Projects\YouTube-To-MP4\node_modules\ytdl-core\lib\index.js:88:12)
    at C:\Users\datha\Desktop\Desktop\VSCode Projects\Serious Projects\YouTube-To-MP4\node_modules\ytdl-core\lib\index.js:20:5
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v20.11.1

Meiscool125 avatar Jul 27 '24 20:07 Meiscool125

Not able to download a youtube video as it is showing that video file is not supported by the files

rudrasgithub avatar Jul 28 '24 03:07 rudrasgithub

just switch to https://www.npmjs.com/package/@distube/ytdl-core it should be a drop in replacement i.e https://github.com/SwapnilSoni1999/spotify-dl/commit/a0605c825ac718d2de68c1bef1a9e15c2747078c

phyzical avatar Jul 28 '24 03:07 phyzical

Thanks @phyzical How to ffmpeg a video Error during extraction: Error: ffmpeg exited with code 1: pipe:1: Invalid argument

ffmpeg(fs.createReadStream('video.mp4')) .setStartTime(0) .setDuration(15) .output(fs.createWriteStream('outputPath.mp4')) .on('end', () => { console.log('Segment extraction finished'); }) .on('error', (err) => { console.error('Error during extraction:', err); }) .run();

rudrasgithub avatar Jul 28 '24 04:07 rudrasgithub

Able to solve it on my own here is the corrected code:

ffmpeg('video.mp4') .setStartTime(0) .setDuration(15) .output(outputPath.mp4') .on('end', () => { console.log('Segment extraction finished'); }) .on('error', (err) => { console.error('Error during extraction:', err); }) .run();

rudrasgithub avatar Jul 28 '24 06:07 rudrasgithub

@MalikElate Yup, I'm getting same thing you should use latest package of ytdl-core => @distube/ytdl-core, I fix the error while doing this!

satyamkr203 avatar Oct 27 '24 10:10 satyamkr203