Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ytdl-core

Package Overview
Dependencies
Maintainers
1
Versions
186
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ytdl-core - npm Package Compare versions

Comparing version 0.9.2 to 0.10.0

3

lib/index.js

@@ -64,2 +64,5 @@ var PassThrough = require('stream').PassThrough;

}
if (options.begin) {
url += '&begin=' + util.fromHumanTime(options.begin);
}

@@ -66,0 +69,0 @@ doDownload(stream, url, options, 3);

3

lib/info.js

@@ -48,2 +48,3 @@ var urllib = require('url');

var id = util.getVideoID(link);
if (id instanceof Error) return callback(id);

@@ -217,3 +218,3 @@ // Try getting config from the video page first.

if (!info.formats.length) {
callback(new Error('Video does not contain any available formats'));
callback(new Error('This video is unavailable'));
return;

@@ -220,0 +221,0 @@ }

@@ -237,6 +237,6 @@ var qs = require('querystring');

if (!id) {
throw new Error('No video id found: ' + link);
return new Error('No video id found: ' + link);
}
if (!idRegex.test(id)) {
throw new Error('Video id (' + id + ') does not match expected format (' + idRegex.toString() + ')');
return new Error('Video id (' + id + ') does not match expected format (' + idRegex.toString() + ')');
}

@@ -411,1 +411,38 @@ return id;

};
/**
* Converts human friendly time to milliseconds. Supports the format
* 00:00:00.000 for hours, minutes, seconds, and milliseconds respectively.
* And 0ms, 0s, 0m, 0h, and together 1m1s.
*
* @param {String|Number} time
* @return {Number}
*/
var numberFormat = /^\d+$/;
var timeFormat = /^(?:(?:(\d+):)?(\d{1,2}):)?(\d{1,2})(?:\.(\d{3}))?$/;
var timeUnits = {
ms: 1,
s: 1000,
m: 60000,
h: 3600000,
};
exports.fromHumanTime = function(time) {
if (typeof time === 'number') { return time; }
if (numberFormat.test(time)) { return +time; }
var firstFormat = timeFormat.exec(time);
if (firstFormat) {
return +(firstFormat[1] || 0) * timeUnits.h +
+(firstFormat[2] || 0) * timeUnits.m +
+(firstFormat[3] || 0) * timeUnits.s +
+(firstFormat[4] || 0);
} else {
var total = 0;
var r = /(\d+)(ms|s|m|h)/g;
var rs;
while ((rs = r.exec(time)) != null) {
total += +rs[1] * timeUnits[rs[2]];
}
return total;
}
};

@@ -9,3 +9,3 @@ {

],
"version": "0.9.2",
"version": "0.10.0",
"repository": {

@@ -28,6 +28,6 @@ "type": "git",

"mocha": "*",
"muk-prop": "^0.5.3",
"muk-prop": "^1.0.0",
"nock": "*",
"sinon": "^1.17.6",
"stream-equal": "~0.1.0"
"stream-equal": "~1.0.0"
},

@@ -34,0 +34,0 @@ "engines": {

@@ -31,2 +31,3 @@ # node-ytdl-core

* `range` - A byte range in the form `INT-INT` that specifies part of the file to download. ie 10355705-12452856. Note that this downloads a portion of the file, and not a separately spliced video.
* `begin` - What time to begin downloading the video, supports formats 00:00:00.000, or 0ms, 0s, 0m, 0h, or number of milliseconds. Example: 1:30, 05:10.123, 10m30s
* `requestOptions` - Anything to merge into the request options which `http.get()` is called with, such as headers.

@@ -33,0 +34,0 @@ * `request` - A function that will be called for each request, instead of ytdl's internal method of making requests. Its signature looks like `Function(url, options, [callback(error, body)]): http.ClientRequest`

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc