Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
req = m3u8stream(format.url, {
chunkReadahead: +info.live_chunk_readahead,
begin: options.begin || format.live && Date.now(),
liveBuffer: options.liveBuffer,
requestOptions: options.requestOptions,
parser: format.isDashMPD ? 'dash-mpd' : 'm3u8',
id: format.itag,
});
req.on('progress', (segment, totalSegments) => {
stream.emit('progress', segment.size, segment.num, totalSegments);
});
} else {
if (options.begin) {
format.url += '&begin=' + parseTime.humanStr(options.begin);
}
let requestOptions = Object.assign({}, options.requestOptions, {
maxReconnects: 6,
maxRetries: 3,
backoff: { inc: 500, max: 10000 },
});
if (options.range && (options.range.start || options.range.end)) {
requestOptions.headers = Object.assign({}, requestOptions.headers, {
Range: `bytes=${options.range.start || '0'}-${options.range.end || ''}`
});
}
req = request(format.url, requestOptions);
req.on('response', (res) => {
if (stream._isDestroyed) { return; }
let shortViewCount = details.shortViewCountText.simpleText;
let rvsDetails = rvsParams.find((elem) => elem.id === details.videoId);
if (!/^\d/.test(shortViewCount)) {
shortViewCount = rvsDetails && rvsDetails.short_view_count_text || '';
}
viewCount = (/^\d/.test(viewCount) ? viewCount : shortViewCount).split(' ')[0];
videos.push({
id: details.videoId,
title: details.title.simpleText,
author: details.shortBylineText.runs[0].text,
ucid: details.shortBylineText.runs[0].navigationEndpoint.browseEndpoint.browseId,
author_thumbnail: details.channelThumbnail.thumbnails[0].url,
short_view_count_text: shortViewCount.split(' ')[0],
view_count: viewCount.replace(',', ''),
length_seconds: details.lengthText ?
Math.floor(parseTime.humanStr(details.lengthText.simpleText) / 1000) :
rvsParams && rvsParams.length_seconds + '',
video_thumbnail: details.thumbnail.thumbnails[0].url,
});
} catch (err) {
continue;
}
}
}
return videos;
};