New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

youtube-mp3-downloader

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

youtube-mp3-downloader - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

@@ -0,0 +0,0 @@ "use strict";

{
"name": "youtube-mp3-downloader",
"version": "0.4.0",
"version": "0.4.1",
"description": "Downloads Youtube videos (in parallel, as streams), encodes the audio data as mp3 and stores them in a defineable location",

@@ -24,3 +24,3 @@ "keywords": [

"progress-stream": "^1.2.0",
"ytdl-core": "^0.7.8"
"ytdl-core": "^0.7.9"
},

@@ -27,0 +27,0 @@ "author": {

@@ -11,12 +11,20 @@ # Youtube MP3 Downloader

### Checkout the project from Github to a local folder
### Installation via NPM
`npm install youtube-mp3-downloader --save`
### Installation from Github
#### Checkout the project from Github to a local folder
`git clone https://github.com/tobilg/youtube-mp3-downloader.git`
### Install module dependencies
#### Install module dependencies
Navigate to the folder where you checked out the project to in your console. Run `npm install`.
### Running
## Running
### Basic example
A basic usage example is the following:

@@ -37,3 +45,3 @@

//Download video and save as MP3 file
YD.download("rnkuRQ8tjIE");
YD.download("xh0ctVznxdM");

@@ -55,3 +63,3 @@ YD.on("finished", function(data) {

```
YD.download("rnkuRQ8tjIE", "Nancy Sinatra - Jackson.mp3");
YD.download("xh0ctVznxdM", "Winter By CyberSDF.mp3");

@@ -64,3 +72,3 @@ ```

{
"videoId": "rnkuRQ8tjIE",
"videoId": "xh0ctVznxdM",
"progress": {

@@ -91,8 +99,8 @@ "percentage": 76.81,

{
"videoId": "rnkuRQ8tjIE",
"file": "/path/to/mp3/folder/Nancy Sinatra & Lee Hazlewood - Jackson.mp3",
"youtubeUrl": "http://www.youtube.com/watch?v=rnkuRQ8tjIE",
"videoTitle": "Nancy Sinatra & Lee Hazlewood - Jackson",
"artist": "Nancy Sinatra & Lee Hazlewood",
"title": "Jackson",
"videoId": "xh0ctVznxdM",
"file": "/path/to/mp3/folder/Winter By CyberSDF.mp3",
"youtubeUrl": "http://www.youtube.com/watch?v=xh0ctVznxdM",
"videoTitle": "Winter By CyberSDF ( Genre : Ambient ) Creative Commons",
"artist": "Unknown",
"title": "Winter By CyberSDF ( Genre : Ambient ) Creative Commons",
"stats": {

@@ -104,2 +112,80 @@ "transferred": 7315910,

}
```
### Detailed example
To use it in a class which provides the downloading functionality, you could use it like this:
**Downloader.js**
```
var YoutubeMp3Downloader = require('youtube-mp3-downloader');
var Downloader = function() {
var self = this;
//Configure YoutubeMp3Downloader with your settings
self.YD = new YoutubeMp3Downloader({
"ffmpegPath": "/path/to/ffmpeg", // Where is the FFmpeg binary located?
"outputPath": "/path/to/mp3/folder", // Where should the downloaded and encoded files be stored?
"youtubeVideoQuality": "highest", // What video quality should be used?
"queueParallelism": 2, // How many parallel downloads/encodes should be started?
"progressTimeout": 2000 // How long should be the interval of the progress reports
});
self.callbacks = {};
self.YD.on("finished", function(data) {
if (self.callbacks[data.videoId]) {
self.callbacks[data.videoId](null,data);
} else {
console.log("Error: No callback for videoId!");
}
});
self.YD.on("error", function(error) {
console.log(error);
});
}
Downloader.prototype.getMP3 = function(track, callback){
var self = this;
// Register callback
self.callbacks[track.videoId] = callback;
// Trigger download
self.YD.download(track.videoId, track.name);
}
module.exports = Downloader;
```
This class can then be used like this:
**usage.js**
```
var Downloader = require("./Downloader");
var dl = new Downloader();
var i = 0;
dl.getMP3({videoId: "xh0ctVznxdM", name: "Winter By CyberSDF.mp3"}, function(err,res){
i++;
if(err)
throw err;
else{
console.log("Song "+ i + " was downloaded: " + res.file);
}
});
dl.getMP3({videoId: "gQH0t8obtEg", name: "United By PlatinumEDM.mp3"}, function(err,res){
i++;
if(err)
throw err;
else{
console.log("Song "+ i + " was downloaded: " + res.file);
}
});
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet