GithubHelp home page GithubHelp logo

fent / node-ytdl-core Goto Github PK

View Code? Open in Web Editor NEW
4.3K 4.3K 717.0 22.68 MB

YouTube video downloader in javascript.

License: MIT License

JavaScript 100.00%
node scraper video-downloader youtube youtube-downloader

node-ytdl-core's Introduction

node-ytdl-core

Depfu codecov Discord

Yet another YouTube downloading module. Written with only Javascript and a node-friendly streaming interface.

Support

You can contact us for support on our chat server

Usage

const fs = require('fs');
const ytdl = require('ytdl-core');
// TypeScript: import ytdl from 'ytdl-core'; with --esModuleInterop
// TypeScript: import * as ytdl from 'ytdl-core'; with --allowSyntheticDefaultImports
// TypeScript: import ytdl = require('ytdl-core'); with neither of the above

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

API

ytdl(url, [options])

Attempts to download a video from the given url. Returns a readable stream. options can have the following, in addition to any getInfo() option and chooseFormat() option.

  • range - A byte range in the form {start: INT, end: INT} that specifies part of the file to download, ie {start: 10355705, end: 12452856}. Not supported on segmented (DASH MPD, m3u8) formats.
    • This downloads a portion of the file, and not a separately spliced video.
  • begin - What time in the video to begin. Supports formats 00:00:00.000, 0ms, 0s, 0m, 0h, or number of milliseconds. Example: 1:30, 05:10.123, 10m30s.
    • For live videos, this also accepts a unix timestamp or Date object, and defaults to Date.now().
    • This option is not very reliable for non-live videos, see #129 and #219.
  • liveBuffer - How much time buffer to use for live videos in milliseconds. Default is 20000.
  • highWaterMark - How much of the video download to buffer into memory. See node's docs for more. Defaults to 512KB.
  • dlChunkSize - When the chosen format is video only or audio only, the download is separated into multiple chunks to avoid throttling. This option specifies the size of each chunk in bytes. Setting it to 0 disables chunking. Defaults to 10MB.
  • IPv6Block - IPv6 block to rotate through, an alternative to using a proxy. Read more. Defaults to undefined.

Event: info

Emitted when the video's info is fetched, along with the chosen format to download.

Event: progress

  • number - Chunk length in bytes or segment number.
  • number - Total bytes or segments downloaded.
  • number - Total bytes or segments.

Emitted whenever a new chunk is received. Passes values describing the download progress.

miniget events

All miniget events are forwarded and can be listened to from the returned stream.

Stream#destroy()

Call to abort and stop downloading a video.

async ytdl.getBasicInfo(url, [options])

Use this if you only want to get metainfo from a video.

async ytdl.getInfo(url, [options])

Gets metainfo from a video. Includes additional formats, and ready to download deciphered URL. This is what the ytdl() function uses internally.

options can have the following

  • requestOptions - Anything to merge into the request options which miniget is called with, such as headers.
  • requestCallback - Provide a callback function that receives miniget request stream objects used while fetching metainfo.
  • lang - The 2 character symbol of a language. Default is en.

ytdl.downloadFromInfo(info, options)

Once you have received metadata from a video with the ytdl.getInfo function, you may pass that information along with other options to this function.

ytdl.chooseFormat(formats, options)

Can be used if you'd like to choose a format yourself. Throws an Error if it fails to find any matching format.

options can have the following

  • quality - Video quality to download. Can be an itag value, a list of itag values, or one of these strings: highest/lowest/highestaudio/lowestaudio/highestvideo/lowestvideo. highestaudio/lowestaudio try to minimize video bitrate for equally good audio formats while highestvideo/lowestvideo try to minimize audio respectively. Defaults to highest, which prefers formats with both video and audio.

    A typical video's formats will be sorted in the following way using quality: 'highest'

    itag container quality codecs                 bitrate  audio bitrate
    18   mp4       360p    avc1.42001E, mp4a.40.2 696.66KB 96KB
    137  mp4       1080p   avc1.640028            4.53MB
    248  webm      1080p   vp9                    2.52MB
    136  mp4       720p    avc1.4d4016            2.2MB
    247  webm      720p    vp9                    1.44MB
    135  mp4       480p    avc1.4d4014            1.1MB
    134  mp4       360p    avc1.4d401e            593.26KB
    140  mp4               mp4a.40.2                       128KB
    

    format 18 at 360p will be chosen first since it's the highest quality format with both video and audio. If you'd like a higher quality format with both video and audio, see the section on handling separate streams.

  • filter - Used to filter the list of formats to choose from. Can be audioandvideo or videoandaudio to filter formats that contain both video and audio, video to filter for formats that contain video, or videoonly for formats that contain video and no additional audio track. Can also be audio or audioonly. You can give a filtering function that gets called with each format available. This function is given the format object as its first argument, and should return true if the format is preferable.

    // Example with custom function.
    ytdl(url, { filter: format => format.container === 'mp4' })
  • format - Primarily used to download specific video or audio streams. This can be a specific format object returned from getInfo.

    • Supplying this option will ignore the filter and quality options since the format is explicitly provided.
// Example of choosing a video format.
let info = await ytdl.getInfo(videoID);
let format = ytdl.chooseFormat(info.formats, { quality: '134' });
console.log('Format found!', format);

ytdl.filterFormats(formats, filter)

If you'd like to work with only some formats, you can use the filter option above.

// Example of filtering the formats to audio only.
let info = await ytdl.getInfo(videoID);
let audioFormats = ytdl.filterFormats(info.formats, 'audioonly');
console.log('Formats with only audio: ' + audioFormats.length);

ytdl.validateID(id)

Returns true if the given string satisfies YouTube's ID format.

ytdl.validateURL(url)

Returns true if able to parse out a valid video ID.

ytdl.getURLVideoID(url)

Returns a video ID from a YouTube URL. Throws an Error if it fails to parse an ID.

ytdl.getVideoID(str)

Same as the above ytdl.getURLVideoID(), but can be called with the video ID directly, in which case it returns it. This is what ytdl uses internally. Throws an Error if it fails to parse an ID.

ytdl.version

The version string taken directly from the package.json.

Limitations

ytdl cannot download videos that fall into the following

  • Regionally restricted (requires a proxy)
  • Private (if you have access, requires cookies)
  • Rentals (if you have access, requires cookies)
  • YouTube Premium content (if you have access, requires cookies)
  • Only HLS Livestreams are currently supported. Other formats will get filtered out in ytdl.chooseFormats

Generated download links are valid for 6 hours, and may only be downloadable from the same IP address.

Ratelimits

When doing too many requests, YouTube might block. This will result in your requests getting denied with HTTP-StatusCode 429. The following Steps might help you:

  • Update ytdl-core to the latest version
  • Use proxies (you can find an example here)
  • Extend on the Proxy Idea by rotating (IPv6-)Addresses
    • read this for more information about this
  • Use cookies (you can find an example here)
    • for this to take effect you have to FIRST wait for the current ratelimit to expire
  • Wait it out (it usually goes away within a few days)

How does using an IPv6 block help?

For request-intensive tasks it might be useful to spread your requests across multiple source IP-Addresses. Changing the source IP that you use is similar to using a proxy, except without bypassing restrictions such as a region lock. More IP-Addresses result in less requests per IP and therefor increase your ratelimit. Since IPv4 Addresses are a limited Resource we advise to use IPv6.

Using an IPv6 block is essentially having millions of IPv6 addresses at your request. In a /64 IPv6 block (which is usually the Block given to a single Household), there are 18,446,744,073,709,551,616 unique IPv6 addresses. This would allow you to make each request with a different IPv6 address.

Even though using an IP-Block does help against ratelimits it requires you to setup your host system to accept http traffic from every message in an IP-Block. We can not help you with the setup for any specific host / hosting provider but searching the internet most likely can.

Handling Separate Streams

Typically 1080p or better videos do not have audio encoded with it. The audio must be downloaded separately and merged via an encoding library. ffmpeg is the most widely used tool, with many Node.js modules available. Use the format objects returned from ytdl.getInfo to download specific streams to combine to fit your needs. Look at example/ffmpeg.js for an example on doing this.

What if it stops working?

YouTube updates their website all the time, it's not that rare for this to stop working. If it doesn't work for you and you're using the latest version, feel free to open up an issue. Make sure to check if there isn't one already with the same error.

Run the tests at test/irl-test.js to make sure this is really an issue with ytdl-core.

npm run test:irl

These tests are not mocked, they try to start downloading a few videos. If these fail, then it's time to debug. If the error you're getting is signature deciphering, check lib/sig.js. Otherwise, the error is likely within lib/info.js.

Install

npm install ytdl-core@latest

Or for Yarn users:

yarn add ytdl-core@latest

Make sure you're installing the latest version of ytdl-core to keep up with the latest fixes.

If you're using a bot or app that uses ytdl-core such as ytdl-core-discord or discord-player, it may be dependent on an older version. To update its ytdl-core version, that library has to update its package.json file, you can't simply change the version on your project's package.json, the app will still use its own older version of ytdl-core.

Look in their repo to see if they already have an active pull request that updates ytdl-core. If they don't, open an issue asking them to update ytdl-core, or better yet, fork the project and submit a pull request with the updated version.

While you wait for the pull reques to merge, you can point to its branch in your package.json

  "ytdl-core-discord": "amishshah/ytdl-core-discord#dependabot/npm_and_yarn/ytdl-core-2.0.1"

Update Checks

The issue of using an outdated version of ytdl-core became so prevalent, that ytdl-core now checks for updates at run time, and every 12 hours. If it finds an update, it will print a warning to the console advising you to update. Due to the nature of this library, it is important to always use the latest version as YouTube continues to update.

If you'd like to disable this update check, you can do so by providing the YTDL_NO_UPDATE env variable.

env YTDL_NO_UPDATE=1 node myapp.js

Related Projects

  • ytdl - A cli wrapper of this.
  • pully - Another cli wrapper of this aimed at high quality formats.
  • ytsr - YouTube video search results.
  • ytpl - YouTube playlist and channel resolver.

Tests

Tests are written with mocha

npm test

node-ytdl-core's People

Contributors

aasim-a avatar andrewrk avatar brunomoreira99 avatar coderaiser avatar daswolke avatar dependabot-preview[bot] avatar depfu[bot] avatar favna avatar fent avatar firecontroller1847 avatar gatecrasher777 avatar greenkeeper[bot] avatar guichaguri avatar hcgrandon avatar mattez02 avatar moisout avatar mtripg6666tdr avatar rafer45 avatar raltamirano avatar roki100 avatar skick1234 avatar svallinn avatar thepieterdc avatar thewsomeguy avatar thiti-dev avatar timeforaninja avatar tinyman avatar vladdrozd avatar waqasibrahim avatar yinglunq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-ytdl-core's Issues

Error: Could not extract signature deciphering actions

      throw er; // Unhandled 'error' event
      ^

Error: Could not extract signature deciphering actions
    at C:\Users\Administrator\Desktop\lll\node_modules\ytdl-core\lib\sig.js:48:11
    at IncomingMessage.<anonymous> (C:\Users\Administrator\Desktop\lll\node_modules\ytdl-core\lib\request.js:34:9)
    at emitNone (events.js:72:20)
    at IncomingMessage.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:905:12)
    at doNTCallback2 (node.js:441:9)
    at process._tickCallback (node.js:355:17)```

What does that means

Error: status code 302
at ClientRequest. (/home/ymp3/node_modules/ytdl-core/lib/index.js:57:28)
at ClientRequest.EventEmitter.emit (events.js:95:17)
at HTTPParser.parserOnIncomingClient as onIncoming
at HTTPParser.parserOnHeadersComplete as onHeadersComplete
at CleartextStream.socketOnData as ondata
at CleartextStream.read as _read
at CleartextStream.Readable.read (_stream_readable.js:320:10)
at EncryptedStream.write as _write
at doWrite (_stream_writable.js:221:10)
at writeOrBuffer (_stream_writable.js:211:5)
at EncryptedStream.Writable.write (_stream_writable.js:180:11)
at write (_stream_readable.js:583:24)

Add support for queried formats.

If a specific format is found via ytdl.getInfo that is not in your pre-existing list, then the app throws an error. For example, The Avengers Trailer in 60fps has a format that is 1080p60, but I can't download it since the itag (299) isn't in your list. So my guess is make an overload for quality to accept the entire format object and go from there? You certainly do not want to maintain a list of formats that can be read from getInfo anyways.

Here is the format object for that video:

{ 
  index: '710-1101',
  fps: '60',
  lmt: '1414683234684860',
  init: '0-709',
  size: '1920x800',
  url: 'http://r6---sn-nx57yn76.googlev...' // truncated to fit
  itag: '299',
  type: 'video/mp4; codecs="avc1.64002a"',
  bitrate: '5513021',
  clen: '72767832'
}

digital envelope routines:EVP_PKEY_get1_RSA:expecting an rsa

hi

i have some errors with this module in the getInfos function, error :

YTDL ERROR : Error: 3054975744:error:0607907F:digital envelope routines:EVP_PKEY_get1_RSA:expecting an rsa key:../../third_party/node/deps/openssl/openssl/crypto/evp/p_lib.c:288:

i use it with node-webkit 0.9.2

an idear?

thanks

Error: could not extract signature deciphering actions

I'm getting this error:

 [Error: could not extract signature deciphering actions,
     at /root/Spotify-to-MP3/node_modules/youtube-mp3-downloader/node_modules/ytdl-core/lib/sig.js:39:11,
     at Request._callback (/root/Spotify-to-MP3/node_modules/youtube-mp3-downloader/node_modules/ytdl-core/lib/crequest.js:9:5),
     at Request.self.callback (/root/Spotify-to-MP3/node_modules/youtube-mp3-downloader/node_modules/ytdl-core/node_modules/request/request.js:197:22),
     at Request.EventEmitter.emit (events.js:98:17),
     at Request.<anonymous> (/root/Spotify-to-MP3/node_modules/youtube-mp3-downloader/node_modules/ytdl-core/node_modules/request/request.js:1050:14),
     at Request.EventEmitter.emit (events.js:117:20),
     at IncomingMessage.<anonymous> (/root/Spotify-to-MP3/node_modules/youtube-mp3-downloader/node_modules/ytdl-core/node_modules/request/request.js:996:12),
     at IncomingMessage.EventEmitter.emit (events.js:117:20),
     at _stream_readable.js:920:16,
     at process._tickCallback (node.js:415:13)]

How do I fix this?

specify a list of quality?

I think it would be better if we can specify a list of quality instead of a specific quality.

For example, if I say

ytdl(url, {
  quality: [141, 140, 139]
});
...

Then what should happen is that it should try to download quality with itag 141, and if such quality is not found, it should try again with 140, and so on.

Video starting time

I'd like to snap a thumbnail of the video at, say 3.2s. Downloading the entire video is slightly overkill... I was wondering if I can specify a start and end time, so when I do use ffmpeg, it'll just be on the first frame.

Error: No such format found: 141

hi ,
1-i set quality such your example but give an error
ytdl(link, { quality: 141 }).pipe(res);
Error: No such format found: 141
,
2- how i can send file to user(pipe) with size and file name with correct format ?
tank you .

Edited

Is there anyway to know if a video has been edited? I didn't see anything from inspecting the info response.

Error: status code 302 - Unhandled 'error' event

Hi,
Sometimes i having error on download.

Here's the error :

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: status code 304
    at ClientRequest.<anonymous> (/Users/Gautier/Documents/heroku/thewok-youtube-dl/node_modules/ytdl-core/lib/index.js:64:16)

Here's my code :

            console.log('Creating stream...');
            file = fs.createWriteStream(tempDir + mp4Title);
            ytdl.downloadFromInfo(info)
                .pipe(file)
                .on('error', function (error) {
                    console.log('Error : ', error);
                    return next(err);
                })
                .on('info', function (info) {
                    console.log('Info : ', info);
                })
                .on('format', function (format) {
                    console.log('format : ', format);
                })
                .on('close', function (data) {
                    convert.convertMP3(title, tempDir, function () {
                        callback(tempDir, mp3Title)
                    });

                });

I don't understand why .on('error') is not receiving anything ( .on('info') neither even when i don't have error and the download is ok.)

Thanks.

No info for itag 141

There's no output for itag 141 (m4a 256kbps), either using this module or the command line
e.g

ytdl https://www.youtube.com/watch\?v\=QcIy9NiNbmo -q 141
No such format found: 141

Cannot read property 'formats' of undefined when I try to downloadFromInfo()

I'm using Express. Everything works fine when using ytdl(url, options), however

var songInfo = ytdl.getInfo('https://www.youtube.com/watch?v=rHLbd3nvu88', { downloadURL: true });

ytdl.downloadFromInfo(songInfo, { filter: 'audioonly' }).pipe(res);

returns this error:

TypeError: Cannot read property 'formats' of undefined
    at downloadFromInfoCallback (/home/vagrant/www/lorem/node_modules/ytdl-core/lib/index.js:44:38)
    at Function.downloadFromInfo (/home/vagrant/www/lorem/node_modules/ytdl-core/lib/index.js:82:3)
    at /home/vagrant/www/lorem/index.js:17:10
    at Layer.handle [as handle_request] (/home/vagrant/www/lorem/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/vagrant/www/lorem/node_modules/express/lib/router/route.js:131:13)
    at Route.dispatch (/home/vagrant/www/lorem/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/home/vagrant/www/lorem/node_modules/express/lib/router/layer.js:95:5)
    at /home/vagrant/www/lorem/node_modules/express/lib/router/index.js:277:22
    at Function.process_params (/home/vagrant/www/lorem/node_modules/express/lib/router/index.js:330:12)
    at next (/home/vagrant/www/lorem/node_modules/express/lib/router/index.js:271:10)
/home/vagrant/www/lorem/node_modules/ytdl-core/lib/sig.js:56
    callback(null, info);
    ^
TypeError: undefined is not a function
    at Object.exports.get (/home/vagrant/www/lorem/node_modules/ytdl-core/lib/sig.js:56:5)
    at gotConfig (/home/vagrant/www/lorem/node_modules/ytdl-core/lib/info.js:160:9)
    at /home/vagrant/www/lorem/node_modules/ytdl-core/lib/info.js:55:9
    at null.<anonymous> (/home/vagrant/www/lorem/node_modules/ytdl-core/lib/info.js:107:5)
    at emit (events.js:107:17)
    at readableAddChunk (/home/vagrant/www/lorem/node_modules/ytdl-core/node_modules/jstream/node_modules/readable-stream/lib/_stream_readable.js:195:16)
    at Readable.push (/home/vagrant/www/lorem/node_modules/ytdl-core/node_modules/jstream/node_modules/readable-stream/lib/_stream_readable.js:162:10)
    at Transform.push (/home/vagrant/www/lorem/node_modules/ytdl-core/node_modules/jstream/node_modules/readable-stream/lib/_stream_transform.js:145:32)
    at CStream.onobjectavailable (/home/vagrant/www/lorem/node_modules/ytdl-core/node_modules/jstream/lib/index.js:126:14)
    at CStream.emit (events.js:129:20)

In fact, when I have this alone

var songInfo = ytdl.getInfo('https://www.youtube.com/watch?v=rHLbd3nvu88', { downloadURL: true });

it throws:

/home/vagrant/www/lorem/node_modules/ytdl-core/lib/sig.js:56
    callback(null, info);
    ^
TypeError: undefined is not a function
    at Object.exports.get (/home/vagrant/www/lorem/node_modules/ytdl-core/lib/sig.js:56:5)
    at gotConfig (/home/vagrant/www/lorem/node_modules/ytdl-core/lib/info.js:160:9)
    at /home/vagrant/www/lorem/node_modules/ytdl-core/lib/info.js:55:9
    at null.<anonymous> (/home/vagrant/www/lorem/node_modules/ytdl-core/lib/info.js:107:5)
    at emit (events.js:107:17)
    at readableAddChunk (/home/vagrant/www/lorem/node_modules/ytdl-core/node_modules/jstream/node_modules/readable-stream/lib/_stream_readable.js:195:16)
    at Readable.push (/home/vagrant/www/lorem/node_modules/ytdl-core/node_modules/jstream/node_modules/readable-stream/lib/_stream_readable.js:162:10)
    at Transform.push (/home/vagrant/www/lorem/node_modules/ytdl-core/node_modules/jstream/node_modules/readable-stream/lib/_stream_transform.js:145:32)
    at CStream.onobjectavailable (/home/vagrant/www/lorem/node_modules/ytdl-core/node_modules/jstream/lib/index.js:126:14)
    at CStream.emit (events.js:129:20)

Remove cheerio dependency

Hi, I managed to get this working for all the tests, also I tested it with other videos.
I'm aware that is not ok to parse HTML with regular expresions, but cheerio is used only once, so I made this regex.

var entities = require('entities');

// get description from #eow-description
var regexString = '<div id="watch-description-text".*?>[\\n\\r\\s]*?'
                + '<p id="eow-description".*?>(.+?)<\/p>[\\n\\r\\s]*?'
                + '<\/div>';
var regex = new RegExp(regexString, 'igm');
var description = regex.exec(body.match(regex));
description = description ? entities.decodeHTML(description[1]) : '';
console.log(description);

where is the bytestotal

i must be missing something, but i need the bytestotal of the video i want to download (for progress as you might have guessed) and i cannot find anything in the info objects i am getting.
( via getInfo() )
besides that:
the info-event never gets fired.
simplified code would be

var stream = fs.createWriteStream('video' + '.' + type));
stream.on('drain', function(){
            trace('drain')
        });
        stream.on('error', function(){
            trace('error')
        });
        stream.on('info', function(){
            trace('info')
        });
        stream.on('end', function(){
            trace('end')
        });
        stream.on('finish', function(){
            trace('fin')
        });
        setInterval(function(){
            trace(stream);
        }, 5000);
        ytdl(url, options).pipe(stream);

Bump version to 0.2.x

Hi Fent,

thanks for the quick fix, can you also bump version to 0.2.x so that I can download the change from npm ? thanks !! I really appreciate it !

Weird, npm test doesn't pass again

Try downloading videos without mocking
http://www.youtube.com/watch?v=qQ31INpjXX0
1) Request status code is not 403 Forbidden
http://www.youtube.com/watch?v=pJk0p-98Xzc
2) Request status code is not 403 Forbidden
http://www.youtube.com/watch?v=mgOS64BF2eU
3) Request status code is not 403 Forbidden
http://www.youtube.com/watch?v=qQ31INpjXX0
4) Request status code is not 403 Forbidden
http://www.youtube.com/watch?v=mvuqS0nxFvA
5) Request status code is not 403 Forbidden

Same error like this : Error: could not extract signature deciphering actions

stream not emitting 'format' event

The README says that request stream will emit a 'format' event: https://github.com/fent/node-ytdl-core#event-format

Looking at the code, I don't think this is happening anymore. Instead the stream is emitting an 'info' event. Is the code wrong, or is the readme wrong?

Another issue is that format used to have a size field (in bytes), and this field is now missing. Is there a way to get the size in bytes before downloading? Otherwise there's no way to have a progress bar.

Add support for Screenshots

It would be great to get screen shots of the video as it was being decoded, say approx. 10/15 frames per second.

Update needed? Error 403

Hello there!
I've been using ytdl for quite some time now and everything was working really good, but since some days now ytdl is unable to get most of the videos I give with an error 4 always, I think that now it cannot download videos by Vevo and before it was able to, also what I've noticed is that I get always this error:

GET http://r8---sn-8qu-t0az.googlevideo.com/videoplayback?sver=3&pl=23&key=yt5&…=jiGfyyV6KAo&initcwndbps=1272500&ratebypass=yes&ipbits=0&expire=1421387690 403 (Forbidden)

This is my code:

ytdl.getInfo(res.data.items[ self.currentIndex ].player["default"], { downloadURL: true }, function(err, data) {
          console.log(self.currentIndex);

          if (err) {
            return console.log(err);

          } else {
            self.loadMusic(data);

And as I say before it was all working perfectly, now it goes up to the (currentIndex) almost the 3th or 4th before giving a working video, and those videos are not good, most of the time they are jokes, covers or dancing lessons, and what im getting from the api (at least the first one, is the original music video, which now doesnt work).

Thank you for your help guys!

Compatibility with browserify

Hi, I'm working in porting this to the browser so it can be used in PhoneGap.

Out of the box, "compiling" this with browserify doesn't work, it seems that it's a problem with the request module (see issue #1737), also the bundle size is around 2.3M.

Here is my progress, the final bundle size is 422k uncompressed, 233k minified and ~65k gzipped.

The first test is failing (download).

Range request

This isn't so much as an issue more a question.
I managed to parse the SIDX from the dash manifest (using the eg: 0-9466 indexRange) to give me the correct byte ranges for a video.
The files are downloaded successfully with a random range passed in, however they are corrupted/unusable.

In a browser you are appending byte-ranges to the sourceBuffer after the init 0-9466 range (I think this describes the sourceBuffer); however AFAIK (please, please correct me here), you cannot say: append 4684226-9996784 on the back of 9466, the next would need to be 9467-

tl;dr Can the files downloaded as ranges be used in anyway on their own. Do they need a but of post work? If so, what?

Thank you & awesome library!

EDIT FOR ANY FUTUR READERS:
You can only write range segments in order. So say you only wanted the first 20secs (as close as the dashing will allow):
var writable = fs.createWriteStream(videoSavePath);
---indexRangeRequest
function __range(r) { YT('https://www.youtube.com/watch?v=' + videoId, { range: r }).on('data', function(buf) { writable.write(buf); }).on('finish', function() { console.log("wrote segment"); __range(nextRange) }); } __range(indexRange);

This didn't suit my needs. I compiled ffmpeg with --enable-openssl and -ss time:code into the downloadUrl

Error : statusCode 403

Hi, Since yesterday i have 403 error for all video.

Using

ytdl.getInfo(
                url,
                [
                    {'downloadURL': true}
                ],
                function (err, info) {
                    ytdl.downloadFromInfo(info)
                        .pipe(file)
                        (other things......)
                })

Thanks

just audio

So, if i want to get just the audio of the video, how would it be?

ytdl('http://youtube/blabal', {filter: 'audio'}).pipe(fs.createWriteStream('audioVideo.mp3'));

Best and great job!

Age confirm issue

I got this error after a while:

500 Error: Error 150: Sign in to confirm your age
 at /var/nodejs/youtube/node_modules/ytdl-core/lib/info.js:47:16
 at Request._callback (/var/nodejs/youtube/node_modules/ytdl-core/lib/crequest.js:9:5)
 at Request.self.callback

connection timeout issue.

what is timeout limit for youtube server.

What is the possible way to prevent timeout for sending multiple simultaneous connection to youtube server for downloading a video?

AudioEncoding is NaN for AAC audio

Hi! I just updated to v0.7.6 and I noticed that some AAC audio streams have NaN listed as their audio encoding. They're also missing the "type" and "clen" headers as well. Sorry to ruin your 0 open issue status, but this issue is breaking my program, since I need the MIME type and Content Length.

Error: status code 403

Did youtube update their api?

My code worked yesterday.

The error:

[9020:0217/192331:ERROR:nw_shell.cc(324)] Error: status code 403
    at Request.<anonymous> (app_path\node_modules\ytdl-core\lib\index.js:67:16)
    at Request.emit (events.js:116:17)
    at Request.onResponse (app_path\node_modules\ytdl-core\node_modules\request\request.js:958:10)
    at ClientRequest.g (events.js:202:16)
    at ClientRequest.emit (events.js:116:17)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:420:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:113:23)
    at Socket.socketOnData (_http_client.js:311:20)
    at Socket.emit (events.js:116:17)
    at readableAddChunk (_stream_readable.js:164:16)
[9020:0217/192331:INFO:CONSOLE(94)] "Uncaught Error: status code 403", source: events.js (94)

Store tokens

What if we store tokens and reuse them I have modified sig to request only once for tokens till now it's working. May this cause any problem in the feature ?

P.S. I did this in my project cause i need to fetch multiple videos from youtube at once.

Is there way to get the info of the video that error'ed?

Hi! I'm building an module to download the videos and convert them to mp3. I'm currently have an issue, because i'm downloading an entire playlist from youtube.

Here is my code:

let streams = _vid.forEach((val) => {
    numVideos++;
    let _stream = ytdl(val, options);
    _stream
      .on('info', (info, format) => {
        fs.stat(path, (err, stats) => {
          if (err) {
            fs.mkdirSync(path);
          }
          self.emit('download', info.title);
          self.createSong(path, info.title, _stream, 192);
        });
      })
      .on('error', (err) => {
        self.emit('error', err);
        numVideos--;
      });
  })

This piece of code is inside of a forEach loop, and i was wondering if i could display the video that was errored to the user. For example, i'm brazilian and some videos are blocked on youtube on my country. When i try to download a video that is blocked, it throws:

[Error: Error 150: Este vídeo apresenta conteúdo de UMG, que o bloqueou no seu país com base nos direitos autorais.]

Is there i way that i could catch the name of the video?

Thanks!!!

Using the range option

How can i know which bit range to specify in the options
if I only have the times which i want to slice out of the original video?

formats.forEach is not a function - version 0.7.0

In version 0.7.0, in sig.js line 76, the code was changed from info.formats.forEach to formats.forEach. Now, sometimes when I run the getInfo function, I get the following exception that exits my script: TypeError: formats.forEach is not a function.

Note that this does not occur with all YouTube URLs supplied, only some, though I'm not sure of any particular pattern.

Put debugging behind an option

Would be nice to be able to disable console.warn and the HTML5 player dump by using an option property. Its doesn't look too good when our program starts dumping random files on the users hard drive, nor does random log output.

best quality audio

I am currently writing a music player written in nodejs that can pull down tracks from youtube. I use ytdl-core to fetch the highest quality video, however in a lot of cases the highest audio quality doesn't need the highest video resolution and as such a lot of data is wasted downloading the higher resolution video.

Could a highestaudio quality option be implemented like in another youtube downloading library pafy?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.