Coder Social home page Coder Social logo

node-ytdl's Introduction

node-ytdl

A youtube downloader written in Javascript. To be used with the command line. If you're looking to use it in your node program, check out ytdl-core.

Depfu codecov

Usage

Streams to stdout by default

ytdl "http://www.youtube.com/watch?v=_HSylqgVYQI" | mpv -

To save to a file

ytdl "http://www.youtube.com/watch?v=_HSylqgVYQI" > myvideo.mp4

or

ytdl -o "{author.name} - {title}" "http://www.youtube.com/watch?v=_HSylqgVYQI"

Download video and convert to mp3 (Requires ffmpeg)

ytdl http://www.youtube.com/watch?v=_HSylqgVYQI | ffmpeg -i pipe:0 -b:a 192K -vn myfile.mp3

Supported options

Usage: ytdl <url> [options]

url     URL to the video.

Options:
   -v, --version                  Print program version.
   -q ITAG, --quality ITAG        Video quality to download, default: highest
   -r INT-INT, --range INT-INT    Byte range to download, ie 10355705-12452856
   -b INT, --begin INT            Time to begin video, format by 1:30.123 and 1m30s
   -o FILE, --output FILE         Save to file, template by {prop}, default: stdout
   --filter STR                   Can be video, videoonly, audio, audioonly
   --filter-container REGEXP      Filter in format container
   --unfilter-container REGEXP    Filter out format container
   --filter-resolution REGEXP     Filter in format resolution
   --unfilter-resolution REGEXP   Filter out format resolution
   --filter-encoding REGEXP       Filter in format encoding
   --unfilter-encoding REGEXP     Filter out format encoding
   -i, --info                     Print video info without downloading
   -j, --info-json                Print video info as JSON without downloading
   --print-url                    Print direct download URL
   --no-cache                     Skip file cache for html5player
   --debug                        Print debug information

Install

npm -g install ytdl

Tests

Tests are written with mocha

npm test

node-ytdl's People

Contributors

andrewrk avatar coderaiser avatar dependabot-preview[bot] avatar depfu[bot] avatar edef1c avatar fent avatar greenkeeper[bot] avatar jspenc72 avatar liuhenry avatar lpender avatar max-mapper avatar pyldin601 avatar renovate[bot] avatar sparcut avatar warren-bank 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

node-ytdl's Issues

your caching addition gives errors

I see there was an update for caching, last month, but ytdl does no longer work for me now :(

$ytdl https://www.youtube.com/watch?v=KCxQ3hYHrZk -o yacht_pearl_white.mp4

gives me:

  var cachefile = path.resolve(os.homedir(), '.ytdl-cache.json');
                                  ^
TypeError: Object #<Object> has no method 'homedir'
    at Object.<anonymous> (/usr/local/lib/node_modules/ytdl/bin/ytdl.js:101:35)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:349:32)
    at Function.Module._load (module.js:305:12)
    at Function.Module.runMain (module.js:490:10)
    at startup (node.js:123:16)
    at node.js:1030:3

downgrading to 0.3.5 (before the cache update) now gives me a key error:

3074569936:error:0607907F:digital envelope routines:EVP_PKEY_get1_RSA:expecting an rsa key:../deps/openssl/openssl/crypto/evp/p_lib.c:288:

I've tried it both on windows 10 and linux (Debian 6.0.10)

( could be that I'm missing something blatantly obvious )

Verbose output

Great script, working fine for me and really easy to get started. Any chance a --verbose mode could be include to see what's going on behind the scenes?

how to use it behind proxy

Hi
if the option can set tunnel for proxy purpose ,that's great.
var tunnel = require('tunnel');
var ytdl = require('ytdl');
var tunnelingAgent = tunnel.httpOverHttp({
proxy : {
host : 'ip',
port : port
}
});

Automatic Signature Deciphering

Looking at the code, it appears you do not employ a sort of dynamic signature deciphering. What I did (in php) was read the html5player.js and figure out how they transform the signature into the 81 character working signature. I suggest you do the same and your code won't require as much updating.

cli broken

~/Downloads ❯ ytdl https://www.youtube.com/watch?v=dEcN8PJDLJA -o xfiles.mp4

title: The X-Files Theme Song
author: HorrorSoundtrack
average rating: 5.0
view count: 10420
length: 3:26
container: mp4
resolution: 720p
encoding: H.264
size: 12.54MB
output: xfiles.mp4


/usr/local/lib/node_modules/ytdl/bin/ytdl.js:221
    ytdl.cache.die();
               ^
TypeError: Cannot call method 'die' of undefined
    at PassThrough.<anonymous> (/usr/local/lib/node_modules/ytdl/bin/ytdl.js:221:16)
    at PassThrough.emit (events.js:98:17)
    at /usr/local/lib/node_modules/ytdl/node_modules/ytdl-core/lib/index.js:35:14
    at Request.<anonymous> (/usr/local/lib/node_modules/ytdl/node_modules/ytdl-core/lib/index.js:72:5)
    at Request.emit (events.js:95:17)
    at Request.onResponse (/usr/local/lib/node_modules/ytdl/node_modules/ytdl-core/node_modules/request/request.js:924:10)
    at ClientRequest.g (events.js:180:16)
    at ClientRequest.emit (events.js:95:17)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (http.js:1688:21)
    at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:121:23)

Tests failing and format metadata not found

I noticed that some of the tests have been failing recently.

  26 passing (15s)
  5 failing

Error: could not extract signature deciphering actions

I guess youtube have updated something on their side. The good news is that youtube-dl is still working so there is a fix.

throw er; // Unhandled 'error' event

Now it seems some error are not catched :

No format metadata for itag 242 found

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: status code 403
    at Request.<anonymous> (/Volumes/Macintosh HD/Users/gabrielstuff/Sources/node/easy-youtube/node_modules/ytdl/lib/index.js:48:30)```

vevo links

hi

i try to decode howto get valid liks for vevo videos but no success

if you can look:

http://www.youtube.com/watch?v=pJk0p-98Xzc

for exemple

we have all the infos but in the params array the link to the video video does not content the signature (we have a s: and the key in the json) if i add it manually it doesn t work neither...

trying el=vevo in your code does not change anything (it used to in another software i made...)

to resume when we have use_cipher_signature: "True" in the videos infos it s bad..

someone made a patch for this but don t understand...

https://gist.github.com/anonymous/e40cb4a1ba3c71f16c05#file-updated-the-algorithm-for-ytcenter-utils-signaturedecipher-function-patch

since today downloading seems harder too...

thanks

++

format.size ?

How to get format.size ? Please provide some example ..

Video download failed on signature extraction

Trying with this youtube link :

The result is all the same :

Error: could not extract signature deciphering actions
    at /Volumes/Macintosh HD/Users/gabrielstuff/Sources/node/easy-youtube/node_modules/ytdl/lib/sig.js:39:13
    at Request._callback (/Volumes/Macintosh HD/Users/gabrielstuff/Sources/node/easy-youtube/node_modules/ytdl/lib/crequest.js:33:7)
    at Request.self.callback (/Volumes/Macintosh HD/Users/gabrielstuff/Sources/node/easy-youtube/node_modules/ytdl/node_modules/request/request.js:123:22)
    at Request.EventEmitter.emit (events.js:98:17)
    at Request.<anonymous> (/Volumes/Macintosh HD/Users/gabrielstuff/Sources/node/easy-youtube/node_modules/ytdl/node_modules/request/request.js:893:14)
    at Request.EventEmitter.emit (events.js:117:20)
    at IncomingMessage.<anonymous> (/Volumes/Macintosh HD/Users/gabrielstuff/Sources/node/easy-youtube/node_modules/ytdl/node_modules/request/request.js:844:12)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:920:16
    at process._tickCallback (node.js:415:13)

Any hints ?

please help: Unhandled stream error in pipe.

way 1:

 var fs = require('fs');
 var ytdl = require('ytdl');
 ytdl('http://www.youtube.com/watch?v=0iQCLlu1dko')
      .pipe(fs.createWriteStream('video.flv'));

or way 2:

 ytdl http://www.youtube.com/watch?v=0iQCLlu1dko > cat.flv

i want to download this video , but both way don't work, error threwed :

stream.js:94
throw er; // Unhandled stream error in pipe.
^

And can you tell me how ytdl works ?
I read the ytdl code , i guess maybe parse the file download http://www.youtube.com/get_video_info?video_id=0iQCLlu1dko , then get urls from url_encoded_fmt_stream_map , but the urls can't download the video , chrome shows Access to the webpage was denied

Youtube changed urls?

How to make a website like this http://www.10youtube.com/ ? I mean get all the possible url with formats .......

Everything is webm now

It used to be able to grab mp4s for every video, then only some, now none. Probably outside of the scope of the library but you could leverage a ffmpeg binding to transcode on the fly so what YT provides doesn't matter.

Not all videos have info.video_verticals and it throws TypeError

Dirty fix:

index.js:258

    if (info.video_verticals) {
      info.video_verticals = info.video_verticals
        .slice(1, -1)
        .split(', ')
        .filter(function(val) { return val !== ''; })
        .map(function(val) { return parseInt(val, 10); })
        ;
    } else {
      info.video_verticals = null;
    }

I need a little help

I'm trying to make the same thing on php, but I cant access to VEVO videos. How does this downloader work with that type of videos? Is there any solutions?

Highest resolution

Hi there,
I hope you can help. I seem to have a problem getting the highest quality of a video.
In my script I don't specify the quality which should default to the highest quality.

Here's an example:
http://www.youtube.com/watch?v=bwK-AM08g2M
when I download it using the above url I get the 360p version not 480p

Also
http://www.youtube.com/watch?v=M7FIvfx5J10
a 720p version is saved instead of 1080p

I am calling the download like this:
ytdl(url)
.pipe(fs.createWriteStream(savefilename));

consider separating the cli into a separate module

I'm packaging up node-ytdl for Debian and to do that I must first package all of its dependencies. I think that if this module was separated into just the library code and a separate command line process it would save me from having to package up all of these dependencies:

├─ ytdl (^0.2.8)
│  ├─ progress-bar (~0.1.1)
│  ├─ nomnom (~1.6.1)
│  │  ├─ colors (0.5.x)
│  │  └─ underscore (~1.4.4)
│  ├─ colors (~0.6.0-1)
│  └─ cliff (~0.1.8)
│     ├─ colors (0.x.x)
│     ├─ winston (0.6.x)
│     │  ├─ eyes (0.1.x)
│     │  ├─ pkginfo (0.3.x)
│     │  ├─ request (2.16.x)
│     │  ├─ colors (0.6.x)
│     │  ├─ async (0.2.x)
│     │  ├─ stack-trace (0.0.x)
│     │  └─ cycle (1.0.x)
│     └─ eyes (0.1.x)

It seems that the code has stopped working

Changed

Actually, the error I get, when calling ytdl from my own code is:

Video not found

I checked res.statusCode and it shows 402

Maybe it's related to making too many requests ?

Video mediainfo

Hi again,

Is it possible to have the video's mediainfo stored in the file?
Its pretty hard to do something with the video's without it.

I don't know if this is a bug or just not build in, so i'm not sure if this is a issue or a surgestion.

But it would be nice if that works :)

Progress info ?

How to get progress info when downloading a video ? Or notification when download finished ?

Allow audio download option

I am working on a music player built with node.js, and one feature I would love to add is an 'add from youtube' button, that allowed the user to download a song from a youtube link into their library.

Would it be possible to add support for downloading of mp3 files?

Thanks for the awesome library!

Signature error (was 403)

Updated to 0.2.2

Instead of 403 I'm not getting this:

# ytdl https://youtu.be/7eVK8ZIFx0k
could not extract signature deciphering actions

Callback on Download completion?

Hi. Sorry if this is not the correct way to request this, but I am using this package and it does everything I need great, however, I had a need to issue a callback when the video download actually completed, and had to modify the source to support this functionality.

Is this something you would be willing to put into future versions?

url argument not found in fish

$ ytdl https://www.youtube.com/watch?v=eeXDl4bVDRw -o file.mp4
No matches for wildcard 'https://www.youtube.com/watch?v=eeXDl4bVDRw'.
fish: ytdl https://www.youtube.com/watch?v=eeXDl4bVDRw -o file.mp4
           ^

url argument is required

Usage: ytdl <url> [options]

url     URL to the video.

Options:
   -v, --version                  Print program version.
   -q ITAG, --quality ITAG        Video quality to download, Default: highest
   -r INT-INT, --range INT-INT    Byte range to download, ie 10355705-12452856
   -o FILE, --output FILE         Where to write the file to, Default: stdout
   --filter-container REGEXP      Filter in format container
   --unfilter-container REGEXP    Filter out format container
   --filter-resolution REGEXP     Filter in format resolution
   --unfilter-resolution REGEXP   Filter out format resolution
   --filter-encoding REGEXP       Filter in format encoding
   --unfilter-encoding REGEXP     Filter out format encoding
   -i, --info                     Print video info without downloading
   --print-url        ~                                                                                                                                                           $ ytdl https://www.youtube.com/watch?v=U6fSEf6tnG4 -o file.mp4
No matches for wildcard 'https://www.youtube.com/watch?v=U6fSEf6tnG4'.
fish: ytdl https://www.youtube.com/watch?v=U6fSEf6tnG4 -o file.mp4
           ^

url argument is required

Usage: ytdl <url> [options]

url     URL to the video.

Options:
   -v, --version                  Print program version.
   -q ITAG, --quality ITAG        Video quality to download, Default: highest
   -r INT-INT, --range INT-INT    Byte range to download, ie 10355705-12452856
   -o FILE, --output FILE         Where to write the file to, Default: stdout
   --filter-container REGEXP      Filter in format container
   --unfilter-container REGEXP    Filter out format container
   --filter-resolution REGEXP     Filter in format resolution
   --unfilter-resolution REGEXP   Filter out format resolution
   --filter-encoding REGEXP       Filter in format encoding
   --unfilter-encoding REGEXP     Filter out format encoding
   -i, --info                     Print video info without downloading
   --print-url

While in bash I get this output:

bash-4.3$ ytdl https://www.youtube.com/watch?v=U6fSEf6tnG4 -o file.mp4

title: Dukes of Hazzard Season 1 intro and credits
author: PaulIsDeadMissHim
average rating: 4.87545776367
view count: 165916
length: 1:32
container: mp4
resolution: 360p
encoding: H.264
size: 5.84MB (6127973 bytes)
output: file.mp4

[##################################################] 100%

Start time ignored

Not sure if I'm doing something wrong, but when I try downloading a video and specifying the start time both from code and from the command line the parameter is ignored. I've tested this on 10 different video urls I grabbed at random.

2 of the 6 tests are failing, start being one of them:

machine:ytdl geuis$ npm test

[email protected] test /usr/local/apps/tacktile/giffer/node_modules/ytdl
mocha -R spec test/*-test.js

ytdl.getInfo()
✓ Returns correct video metainfo (86ms)

ytdl.getInfo() from a non-existant video
✓ Should give an error

download
1) Should be pipeable and data equal to stored file

download with start
2) Should be pipeable and data equal to stored file

util.parseTime()
✓ Returns milliseconds if given numbers
✓ Works with minutes and seconds
✓ And even only hours and milliseconds

util.signatureDecipher()
✓ Returns the correct signature

6 passing (4s)
2 failing

  1. download Should be pipeable and data equal to stored file:
    Error: timeout of 2000ms exceeded
    at Object. (/usr/local/share/npm/lib/node_modules/mocha/lib/runnable.js:165:14)
    at Timer.list.ontimeout (timers.js:101:19)

  2. download with start Should be pipeable and data equal to stored file:
    Error: timeout of 2000ms exceeded
    at Object. (/usr/local/share/npm/lib/node_modules/mocha/lib/runnable.js:165:14)
    at Timer.list.ontimeout (timers.js:101:19)

Invalid url?

I feel this is like a stupid question but how do I know if a url is valid or not?

I've tried:

    ytdl.getInfo(link, function(err, info) {
        if(err) return console.log(err);
        else return console.log(info);
    });

This code still gives me a 500 error code saying "No video id found". Am I missing something really easy here?

Thank you in advance.

EDIT:
I've tried surrounding the function with try/catch and catch the error there, which lets me catch the error. I guess I'm looking for a more callback error approach. Is there anything like this in this module?

Error using this plugin

Hello,

I followed the instructions for downloading a video and ended up with an error that resulted in:

1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c;1;1;112;112;1;0x1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;

The video never actually downloaded. Not sure if this is something on my end, but I figured I'd mention this.

Create corrupted mp3 file?

What is the correct way to save the video as a .mp3 file?

Try this one:
ytdl ttps://www.youtube.com/watch?v=_GQW7jqezqA > test.mp3 --filter audioonly

The output of this command is a corrupted mp3 file. But if I do, > test.mp4 --filter audio it's perfect

Error code 150 - not available in your country strange behavor

node-ytdl and ytdl-core seem to be failing at fetching youtube videos that are available in the server's country and can be successfully downloaded using youtube-dl

Tested with:

ytdl v2AC41dglnM

Which failed with error code: Code 150: The uploader has not made this video available in your country.

While testing youtube-dl

youtube-dl -v v2AC41dglnM

Resulted in no issues.

Valid Url throws TypeError

Hi, thank you for this great library.
I found a strange bug for this url, which is working in the browser, but when trying to get infos it throws

ytdl -i 'http://www.youtube.com/watch?v=YntYV3ty-UU'

TypeError: Parameter 'url' must be a string, not undefined
at Url.parse (url.js:107:11)
at Object.urlParse as parse
at /usr/local/share/npm/lib/node_modules/ytdl/lib/index.js:213:31
at Array.map (native)
at Request._callback (/usr/local/share/npm/lib/node_modules/ytdl/lib/index.js:211:10)
at Request.self.callback (/usr/local/share/npm/lib/node_modules/ytdl/node_modules/request/main.js:120:22)
at Request.EventEmitter.emit (events.js:98:17)
at Request. (/usr/local/share/npm/lib/node_modules/ytdl/node_modules/request/main.js:555:16)
at Request.EventEmitter.emit (events.js:95:17)
at IncomingMessage. (/usr/local/share/npm/lib/node_modules/ytdl/node_modules/request/main.js:517:14)

The last working version is: v0.1.16 which gives this error:
[Error: No such format for itag 78 found]

Thank you

When using 'range' option the output video is unreadable

When I run the following, I get a functioning mp4 video that lasts for 2 seconds then freezes for the remaining 5 seconds (original YT video is 7 seconds, 300kb):

ytdl(url, { filter: function(format) { return format.container === 'mp4'; }, range:"0-85714", quality:
"highest" })
  .pipe(fs.createWriteStream('video.mp4'));

When I run this:

ytdl(url, { filter: function(format) { return format.container === 'mp4'; }, range:"42857-85714", quality:
"highest" })
  .pipe(fs.createWriteStream('video.mp4'));

I would expect to get an mp4 with 1 second duration starting from the offset of 1 second. The files size looks correct in that it is returning the appropriate number of bytes, but I believe the video is not getting its duration / dimension meta data and is not playable.

Am I doing something wrong?

status code 403

$ ./ytdl.js http://www.youtube.com/watch?v=mgOS64BF2eU

Error: status code 403
at Request. (/var/www/nytd.us/music/download/node_modules/ytdl/lib/index.js:125:35)
at Request.EventEmitter.emit (events.js:95:17)
at Request.onResponse (/var/www/nytd.us/music/download/node_modules/ytdl/node_modules/request/request.js:812:10)
at ClientRequest.g (events.js:175:14)
at ClientRequest.EventEmitter.emit (events.js:95:17)
at HTTPParser.parserOnIncomingClient as onIncoming
at HTTPParser.parserOnHeadersComplete as onHeadersComplete
at Socket.socketOnData as ondata
at TCP.onread (net.js:525:27)

Access Denied On Live Server

First of all great work and contribution. Your script works great if i run it on my local machine , but the moment i upload it on a live node Js server , the generated link for youtube returns with access denied.

1 possibility i found is the generated URL contains IP address of the server, whereas some other popular services over the web creates download link with user IP address.

Also you can get a live demo http://voulmepunch.ap01.aws.af.cm/video/VhQK-6iI7cI , you can check network console to see the download link returned via ajax.

[Error: could not extract signature deciphering actions]

Hi fent,

I noticed the bug coming up recently which was resolved by you guys before. In addition, there are five related tests failed in node-ytdl-core. If you want to give it a try, you can use this link http://www.youtube.com/watch?v=m65jhGwtWrg&feature=youtube_gdata

[Error: could not extract signature deciphering actions]

Hope this information helps, thanks

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.