Socket
Socket
Sign inDemoInstall

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 4.0.3 to 4.0.4

7

lib/cache.js

@@ -8,2 +8,5 @@ // A cache that expires.

set(key, value) {
if (this.has(key)) {
clearTimeout(super.get(key).tid);
}
super.set(key, {

@@ -21,7 +24,7 @@ tid: setTimeout(this.delete.bind(this, key), this.timeout),

}
async getOrSet(key, fn) {
getOrSet(key, fn) {
if (this.has(key)) {
return this.get(key);
} else {
let value = await fn();
let value = fn();
this.set(key, value);

@@ -28,0 +31,0 @@ return value;

@@ -46,3 +46,3 @@ const PassThrough = require('stream').PassThrough;

});
stream.destroy = () => { stream._isDestroyed = true; };
stream._destroy = () => { stream.destroyed = true; };
return stream;

@@ -55,3 +55,3 @@ };

[
'abort', 'request', 'response', 'error', 'redirect', 'retry', 'reconnect',
'abort', 'request', 'response', 'error', 'close', 'redirect', 'retry', 'reconnect',
].forEach(event => {

@@ -93,3 +93,3 @@ req.prependListener(event, stream.emit.bind(stream, event));

stream.emit('info', info, format);
if (stream._isDestroyed) { return; }
if (stream.destroyed) { return; }

@@ -152,3 +152,3 @@ let contentLength, downloaded = 0;

req.on('end', () => {
if (stream._isDestroyed) { return; }
if (stream.destroyed) { return; }
if (end && end !== rangeEnd) {

@@ -175,3 +175,3 @@ start = end + 1;

req.on('response', res => {
if (stream._isDestroyed) { return; }
if (stream.destroyed) { return; }
contentLength = contentLength || parseInt(res.headers['content-length']);

@@ -184,8 +184,6 @@ });

stream.destroy = () => {
stream._isDestroyed = true;
if (req.abort) req.abort();
stream._destroy = () => {
stream.destroyed = true;
req.destroy();
req.end();
req.removeListener('data', ondata);
req.unpipe();
};

@@ -192,0 +190,0 @@ };

@@ -165,3 +165,3 @@ const utils = require('./utils');

} catch (err) {
continue;
// Skip.
}

@@ -168,0 +168,0 @@ }

@@ -32,5 +32,5 @@ const urllib = require('url');

* @returns {Promise<Object>}
*/
*/
exports.getBasicInfo = async(id, options) => {
const retryOptions = Object.assign({}, miniget.Defaults, options.requestOptions);
const retryOptions = Object.assign({}, miniget.defaultOptions, options.requestOptions);
let info = await retryFn(getJSONWatchPage, [id, options], retryOptions);

@@ -43,3 +43,3 @@ let player_response =

let playErr = utils.playError(player_response, ['ERROR', 'UNPLAYABLE']);
let playErr = utils.playError(player_response, ['ERROR']);
let privateErr = privateVideoError(player_response);

@@ -55,3 +55,2 @@ if (playErr || privateErr) {

let [embedded_player_response, embedbody] = await retryFn(getEmbedPage, [id, options], retryOptions);
playErr = utils.playError(player_response, ['LOGIN_REQUIRED']);
player_response = embedded_player_response;

@@ -110,4 +109,3 @@ html5player = html5player || getHTML5player(embedbody);

const getWatchURL = (id, options) =>
`${VIDEO_URL + id}&hl=${options.lang || 'en'}&bpctr=${Math.ceil(Date.now() / 1000)}`;
const getWatchURL = (id, options) => `${VIDEO_URL + id}&hl=${options.lang || 'en'}`;
const getWatchPage = (id, options) => {

@@ -158,5 +156,3 @@ const url = getWatchURL(id, options);

const parseJSON = (source, json) => {
if (!json) {
return null;
} else if (typeof json === 'object') {
if (!json || typeof json === 'object') {
return json;

@@ -275,2 +271,5 @@ } else {

info.html5player = info.html5player || getHTML5player(await getWatchPage(id, options));
if (!info.html5player) {
throw Error('Unable to find html5player file');
}
const html5player = urllib.resolve(VIDEO_URL, info.html5player);

@@ -277,0 +276,0 @@ funcs.push(sig.decipherFormats(info.formats, html5player, options));

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

],
"version": "4.0.3",
"version": "4.0.4",
"repository": {

@@ -40,4 +40,4 @@ "type": "git",

"html-entities": "^1.3.1",
"m3u8stream": "^0.8.0",
"miniget": "^2.1.0",
"m3u8stream": "^0.8.1",
"miniget": "^3.0.0",
"sax": "^1.1.3"

@@ -52,3 +52,3 @@ },

"muk-require": "^1.2.0",
"nock": "^12.0.0",
"nock": "^13.0.4",
"nyc": "^15.0.0",

@@ -55,0 +55,0 @@ "sinon": "^9.0.0",

@@ -343,15 +343,8 @@ declare module 'ytdl-core' {

author?: string;
length_seconds?: string;
iurlmq?: string;
ucid?: string;
author_thumbnail?: string;
short_view_count_text?: string;
session_data: string;
endscreen_autoplay_session_data?: string;
iurlhq?: string;
playlist_iurlhq?: string;
playlist_title?: string;
playlist_length?: string;
playlist_iurlmq?: string;
video_id?: string;
list?: string;
thumbnail_ids?: string;
view_count?: string;
length_seconds?: number;
video_thumbnail?: string;
}

@@ -358,0 +351,0 @@

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