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.2.3 to 0.2.4

test/html5player.json

2

lib/info.js

@@ -97,3 +97,3 @@ var qs = require('querystring');

if (downloadURL) {
sig.get(link, info, callback);
sig.get(link, info, requestOptions.debug, callback);
} else {

@@ -100,0 +100,0 @@ callback(null, info);

@@ -0,1 +1,3 @@

var fs = require('fs');
var path = require('path');
var url = require('url');

@@ -12,5 +14,6 @@ var util = require('./util');

* @param {Object} info
* @param {Boolean} debug
* @param {Function(Error, String)} callback
*/
exports.get = function(link, info, callback) {
exports.get = function(link, info, debug, callback) {
if (info.use_cipher_signature) {

@@ -38,2 +41,14 @@ crequest(link, function(err, body) {

if (!tokens) {
if (debug) {
var filename = path.basename(config.assets.js);
var filepath = path.resolve(
__dirname, '../tests/files/html5player/' + filename);
fs.writeFile(filepath, body);
var name = path.basename(filename, '.js');
var html5player = require('../test/html5player.json');
html5player[name] = [];
fs.writeFile(
path.resolve(__dirname, '../test/html5player.json'),
JSON.stringify(html5player, null, 2));
}
callback(

@@ -51,3 +66,3 @@ new Error('could not extract signature deciphering actions'));

var sig = exports.decipher(tokens, format.s);
format.url = exports.getDownloadURL(format, sig);
format.url = exports.getDownloadURL(format, sig, debug);
return format;

@@ -70,3 +85,3 @@ });

var sig = format.sig || '';
format.url = exports.getDownloadURL(format, sig);
format.url = exports.getDownloadURL(format, sig, debug);
});

@@ -81,4 +96,6 @@ callback(null, info);

* @param {Array.<String>} tokens
* @param {Boolean} debug
* @return {!String}
*/
exports.getDownloadURL = function(format, sig) {
exports.getDownloadURL = function(format, sig, debug) {
var decodedUrl;

@@ -98,4 +115,6 @@ if (format.url) {

} else {
console.warn('download url not found for itag ' + format.itag);
return;
if (debug) {
console.warn('download url not found for itag ' + format.itag);
}
return null;
}

@@ -106,4 +125,6 @@

} catch (err) {
console.warn('could not decode url: ' + err.message);
return;
if (debug) {
console.warn('could not decode url: ' + err.message);
}
return null;
}

@@ -110,0 +131,0 @@

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

* @param {Object} info
* @param {Boolean} debug
* @return {Array.<Object>}
*/
exports.parseFormats = function(info) {
exports.parseFormats = function(info, debug) {
var formats = [];

@@ -175,3 +176,3 @@ if (info.url_encoded_fmt_stream_map) {

var meta = FORMATS[data.itag];
if (!meta) {
if (!meta && debug) {
console.warn('No format metadata for itag ' + data.itag + ' found');

@@ -178,0 +179,0 @@ }

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

],
"version": "0.2.3",
"version": "0.2.4",
"repository": {

@@ -18,3 +18,3 @@ "type": "git",

"scripts": {
"test": "mocha -R spec -t 4000 test/*-test.js"
"test": "mocha -R spec -t 8000 test/*-test.js"
},

@@ -21,0 +21,0 @@ "dependencies": {

@@ -6,8 +6,3 @@ var sig = require('../lib/sig');

var html5playerfiles = {
vfl0Cbn9e: ['w15', 'w44', 'r', 'w24', 's3', 'r', 'w2', 'w50'],
vfl5aDZwb: ['w15', 'w44', 'r', 'w24', 's3', 'r', 'w2', 'w50'],
vflqZIm5b: ['w1', 'w32', 's1', 'r', 's3', 'r', 's3', 'r'],
vfl9FYC6l: ['w28', 'r', 'p1', 'w26', 'w40', 'r', 'p1'],
};
var html5player = require('./html5player.json');

@@ -18,8 +13,8 @@

it('Returns the correct set of actions', function() {
for (var name in html5playerfiles) {
for (var name in html5player) {
var filepath = path.resolve(
__dirname, 'files/html5player/html5player-en_US-' + name + '.js');
__dirname, 'files/html5player/html5player-' + name + '.js');
var body = fs.readFileSync(filepath, 'utf8');
var actions = sig.extractActions(body);
assert.deepEqual(actions, html5playerfiles[name]);
assert.deepEqual(actions, html5player[name]);
}

@@ -50,3 +45,3 @@ });

it('real set of tokens', function() {
testDecipher(html5playerfiles.vfl0Cbn9e,
testDecipher(html5player['en_US-vfl0Cbn9e'],
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',

@@ -53,0 +48,0 @@ 'bbSdefghijklmnoaqrstuvwxyzAZCDEFGHIJKLMNOPQRpTUVWc');

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