Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

Commit

Permalink
document ytdl.exec() with audio example
Browse files Browse the repository at this point in the history
  • Loading branch information
fent committed May 9, 2015
1 parent e7cc0d5 commit 2b8333f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
*.mp4
*.webm
*.srt
*.mp3
*.m4a
node_modules
bin
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,19 @@ Will print something like
24video
3sat

## Call the `youtube-dl` binary directly

This module doesn't have `youtube-dl` download the video. Instead, it uses the `url` key from the `--dump-json` CLI option to create a node stream. That way, it can be used like any other node stream.

If that, or none of the above support your use case, you can use `ytdl.exec()` to call `youtube-dl` however you like.

```javascript
ytdl.exec(url, ['-x', '--audio-format', 'mp3'], {}, function(err, output) {
if (err) throw err;
console.log(output.join('\n'));
});
```

# Install

npm install youtube-dl
Expand Down
8 changes: 8 additions & 0 deletions example/audio.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var ytdl = require('..');


var url = 'https://www.youtube.com/watch?v=H7HmzwI67ec';
ytdl.exec(url, ['-x', '--audio-format', 'mp3'], {}, function(err, output) {
if (err) throw err;
console.log(output.join('\n'));
});

0 comments on commit 2b8333f

Please sign in to comment.