This repository has been archived by the owner on Dec 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
129 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,32 @@ | ||
youtubedl = require('./../lib/youtube-dl'); | ||
|
||
|
||
// will be called when a state changes | ||
stateChange = function(state, data) { | ||
console.log(state); | ||
if (state == 'Downloading video') { | ||
console.log('Video size: ' + data.size); | ||
} | ||
} | ||
dl = youtubedl.download('http://www.youtube.com/watch?v=90AiXO1pAiA', './', | ||
// optional arguments passed to youtube-dl | ||
['--max-quality=18']); | ||
|
||
|
||
// will be called when the download starts | ||
dl.on('download', function(data) { | ||
console.log('Download started'); | ||
console.log('Video size: ' + data.size); | ||
}); | ||
|
||
// will be called during download progress of a video | ||
progress = function(data) { | ||
dl.on('progress', function(data) { | ||
process.stdout.write(data.eta + ' ' + data.percent + '% at ' + data.speed + '\r'); | ||
} | ||
}); | ||
|
||
// catches any errors | ||
dl.on('error', function(err) { | ||
throw err; | ||
}); | ||
|
||
// called when youtube-dl finishes | ||
finished = function(err, data) { | ||
if (err) | ||
throw err; | ||
dl.on('end', function(data) { | ||
console.log('\nDownload finished!'); | ||
console.log('Time Taken: ' + data.timeTaken); | ||
console.log('Time Taken in ms: ' + data.timeTakenms); | ||
console.log('Average Speed: ' + data.averageSpeed); | ||
}, | ||
|
||
youtubedl.download('http://www.youtube.com/watch?v=90AiXO1pAiA', './', | ||
stateChange, progress, finished, | ||
|
||
// optional arguments passed to youtube-dl | ||
['--max-quality=18']); | ||
console.log('Average Speed in Bytes: ' + data.averageSpeedBytes); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.