ytdl-core
Advanced tools
Comparing version 4.0.5 to 4.0.6
@@ -59,10 +59,2 @@ const PassThrough = require('stream').PassThrough; | ||
req.pipe(stream, { end }); | ||
// Emit `close` only when stream is already destroyed, in case there are multiple requests | ||
// due to playlists, chunking, and reconnects. | ||
req.on('close', () => { | ||
if (stream.destroyed) { | ||
stream.emit('close'); | ||
} | ||
}); | ||
}; | ||
@@ -69,0 +61,0 @@ |
@@ -125,9 +125,7 @@ const urllib = require('url'); | ||
try { | ||
const newInfo = await retryFunc(func, args, retryOptions); | ||
const newInfo = await retryFunc(func, args.concat([info]), retryOptions); | ||
if (newInfo.player_response) { | ||
if (newInfo.player_response.videoDetails) { | ||
newInfo.player_response.videoDetails = assign( | ||
info && info.player_response && info.player_response.videoDetails, | ||
newInfo.player_response.videoDetails); | ||
} | ||
newInfo.player_response.videoDetails = assign( | ||
info && info.player_response && info.player_response.videoDetails, | ||
newInfo.player_response.videoDetails); | ||
newInfo.player_response = assign(info && info.player_response, newInfo.player_response); | ||
@@ -188,3 +186,3 @@ } | ||
} catch (err) { | ||
if (err instanceof miniget.MinigetError || currentTry >= options.maxRetries) { | ||
if ((err instanceof miniget.MinigetError && err.statusCode < 500) || currentTry >= options.maxRetries) { | ||
throw err; | ||
@@ -215,2 +213,10 @@ } | ||
const findPlayerResponse = (source, info) => { | ||
const player_response = info && ( | ||
(info.player && info.player.args && info.player.args.player_response) || | ||
info.player_response || info.playerResponse || info.embedded_player_response); | ||
return parseJSON(source, player_response); | ||
}; | ||
const getWatchJSONURL = (id, options) => `${getWatchURL(id, options)}&pbj=1`; | ||
@@ -246,6 +252,3 @@ const getJSONWatchPage = async(id, options) => { | ||
let info = parsedBody.reduce((part, curr) => Object.assign(curr, part), {}); | ||
let player_response = | ||
(info.player && info.player.args && info.player.args.player_response) || | ||
info.player_response || info.playerResponse; | ||
info.player_response = parseJSON('watch.json `player_response`', player_response); | ||
info.player_response = findPlayerResponse('watch.json `player_response`', info); | ||
info.player_response.videoDetails = Object.assign({}, info.player_response.videoDetails, { age_restricted: false }); | ||
@@ -274,3 +277,3 @@ info.html5player = info.player && info.player.assets && info.player.assets.js; | ||
const getEmbedURL = (id, options) => `${EMBED_URL + id}?hl=${options.lang || 'en'}`; | ||
const getEmbedPage = async(id, options) => { | ||
const getEmbedPage = async(id, options, watchPageInfo) => { | ||
const embedUrl = getEmbedURL(id, options); | ||
@@ -284,6 +287,6 @@ let body = await miniget(embedUrl, options.requestOptions).text(); | ||
let info = config.args || config; | ||
let player_response = (info && (info.player_response || info.embedded_player_response)) || | ||
config.embedded_player_response; | ||
info.player_response = parseJSON('embed `player_response`', player_response); | ||
info.player_response.videoDetails = Object.assign({}, info.player_response.videoDetails, { age_restricted: true }); | ||
info.player_response = findPlayerResponse('embed `player_response`', info); | ||
info.player_response.videoDetails = Object.assign({}, info.player_response.videoDetails, { | ||
age_restricted: watchPageInfo && !!utils.playError(watchPageInfo.player_response, ['LOGIN_REQUIRED']), | ||
}); | ||
info.html5player = getHTML5player(body); | ||
@@ -312,3 +315,3 @@ return info; | ||
let info = querystring.parse(body); | ||
info.player_response = parseJSON('get_video_info `player_response`', info.player_response); | ||
info.player_response = findPlayerResponse('get_video_info `player_response`', info); | ||
return info; | ||
@@ -315,0 +318,0 @@ }; |
@@ -9,3 +9,3 @@ { | ||
], | ||
"version": "4.0.5", | ||
"version": "4.0.6", | ||
"repository": { | ||
@@ -40,4 +40,4 @@ "type": "git", | ||
"html-entities": "^1.3.1", | ||
"m3u8stream": "^0.8.1", | ||
"miniget": "^3.0.0", | ||
"m3u8stream": "^0.8.2", | ||
"miniget": "^4.0.0", | ||
"sax": "^1.1.3" | ||
@@ -44,0 +44,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
82176
2227
- Removedminiget@3.1.1(transitive)
Updatedm3u8stream@^0.8.2
Updatedminiget@^4.0.0