przemyslawpluta / node-youtube-dl

youtube-dl driver for node
MIT License
1.71k stars 366 forks source link

twitch VOD download not working #305

Open keja opened 4 years ago

keja commented 4 years ago

Hello,

Im facing some issues when i try to get a Twitch video, it works perfect when i use the binary file, so i expect the following code to work:

const VOD = youtubedl("https://www.twitch.tv/videos/598800710");

yet i produces a file that is 758bytes, and it is a 40min video.

i dont know if this is a bug, or im not getting something right ?

here is what i have tried:

const youtubedl = require('youtube-dl');
const fs = require('fs');
const exec = require('child_process').exec;

(async () => {
    const urls = [
        "https://www.youtube.com/watch?v=dQw4w9WgXcQ", 
        "https://www.twitch.tv/videos/598800710"
    ];

    console.log('using youtubedl');
    for(const idx in urls){
        await new Promise(r => {
            const video = youtubedl(urls[idx]);
            video.on('info', function(info) {
                console.log(`  ${info.extractor} -> ${urls[idx]}`);
                video.pipe(fs.createWriteStream(`file_a_${idx}.mp4`));
            })
            video.on('end', function(){
                console.log(`  file size: ${fs.statSync(`file_a_${idx}.mp4`).size}`);
                console.log();
                r();
            })
        });
    }

    console.log('using bin');
    for(const idx in urls){
        await new Promise(r => {

            console.log(`  ${urls[idx]}`);
            const child = exec(`${youtubedl.getYtdlBinary()} -o "file_b_${idx}.mp4" -f "[ext=mp4]" "${urls[idx]}"`);
            child.on('exit', () => {
                const s = fs.statSync(`file_b_${idx}.mp4`).size;
                console.log(`  file size: ${s}`);
                console.log();
                r();
            });

        });
    }
})();

and the output is

using youtubedl
  youtube -> https://www.youtube.com/watch?v=dQw4w9WgXcQ
  file size: 15929856

  twitch:vod -> https://www.twitch.tv/videos/598800710
  file size: 758

using bin
  https://www.youtube.com/watch?v=dQw4w9WgXcQ
  file size: 15929856

  https://www.twitch.tv/videos/598800710
  file size: 1857375989
ghost commented 4 years ago

see https://github.com/przemyslawpluta/node-youtube-dl/issues/294

keja commented 4 years ago

see #294

Thanks!

masudhossain commented 3 years ago

@keja were you able to fix this twitch video download issue?