youtubei.js
Advanced tools
Comparing version 1.4.4 to 1.4.5
@@ -72,6 +72,6 @@ 'use strict'; | ||
quality: '360p', // if a video doesn't have a specific quality it'll fall back to 360p, this is ignored when type is set to audio | ||
type: 'videoandaudio' // can be “video”, “audio” and “videoandaudio” | ||
type: 'audio' // can be “video”, “audio” and “videoandaudio” | ||
}); | ||
stream.pipe(fs.createWriteStream(`./${search.videos[0].id}.mp4`)); | ||
stream.pipe(fs.createWriteStream(`./${search.videos[0].id}.m4a`)); | ||
@@ -83,4 +83,9 @@ stream.on('start', () => { | ||
stream.on('info', (info) => { | ||
console.log(info) | ||
console.info('[DOWNLOADER]', `Downloading ${info.video_details.title} by ${info.video_details.metadata.channel_name}`); | ||
}); | ||
stream.on('progress', (data) => { | ||
console.info('[DOWNLOADER]', data); | ||
}); | ||
@@ -87,0 +92,0 @@ stream.on('end', () => { |
@@ -486,6 +486,12 @@ 'use strict'; | ||
options.format = options.format || 'mp4'; | ||
const payload = { | ||
client: 'ANDROID', | ||
videoId: video_id | ||
}; | ||
const response = await this.request.post('/player', payload); | ||
const streaming_data = this.#chooseFormat(options, response.data); | ||
const data = await this.actions.getVideoInfo(video_id); | ||
const streaming_data = this.#chooseFormat(options, data); | ||
if (!streaming_data.selected_format) | ||
@@ -524,3 +530,11 @@ throw new Utils.NoStreamingDataError('Could not find any suitable format.', { video_id, options }); | ||
const stream = new Stream.PassThrough(); | ||
this.actions.getVideoInfo(video_id, cpn).then(async (video_data) => { | ||
const payload = { | ||
client: 'ANDROID', | ||
videoId: video_id | ||
}; | ||
this.request.post('/player', payload).then(async ({ data }) => { | ||
const video_data = data; | ||
if (video_data.playabilityStatus.status === 'LOGIN_REQUIRED') | ||
@@ -527,0 +541,0 @@ return stream.emit('error', { message: 'You must login to download age-restricted videos.', error_type: 'LOGIN_REQUIRED', playability_status: video_data.playabilityStatus.status }); |
@@ -182,6 +182,6 @@ 'use strict'; | ||
const details = this.data.videoDetails; | ||
const microformat = this.data.microformat.playerMicroformatRenderer; | ||
const microformat = this.data?.microformat?.playerMicroformatRenderer; | ||
const streaming_data = this.data.streamingData; | ||
const mf_raw_data = Object.entries(microformat); | ||
const mf_raw_data = Object.entries(microformat || {}); | ||
const dt_raw_data = Object.entries(details); | ||
@@ -196,16 +196,18 @@ | ||
}; | ||
// Extracts most of the metadata | ||
mf_raw_data.forEach((entry) => { | ||
const key = Utils.camelToSnake(entry[0]); | ||
if (Constants.METADATA_KEYS.includes(key)) { | ||
key == 'view_count' && (processed_data.metadata[key] = parseInt(entry[1])) || | ||
key == 'owner_profile_url' && (processed_data.metadata.channel_url = entry[1]) || | ||
key == 'owner_channel_name' && (processed_data.metadata.channel_name = entry[1]) || | ||
(processed_data.metadata[key] = entry[1]); | ||
} else { | ||
processed_data[key] = entry[1]; | ||
} | ||
}); | ||
if (microformat) { | ||
// Extracts most of the metadata | ||
mf_raw_data.forEach((entry) => { | ||
const key = Utils.camelToSnake(entry[0]); | ||
if (Constants.METADATA_KEYS.includes(key)) { | ||
key == 'view_count' && (processed_data.metadata[key] = parseInt(entry[1])) || | ||
key == 'owner_profile_url' && (processed_data.metadata.channel_url = entry[1]) || | ||
key == 'owner_channel_name' && (processed_data.metadata.channel_name = entry[1]) || | ||
(processed_data.metadata[key] = entry[1]); | ||
} else { | ||
processed_data[key] = entry[1]; | ||
} | ||
}); | ||
} | ||
// Extracts extra details | ||
@@ -212,0 +214,0 @@ dt_raw_data.forEach((entry) => { |
{ | ||
"name": "youtubei.js", | ||
"version": "1.4.4", | ||
"version": "1.4.5", | ||
"description": "A full-featured wrapper around the InnerTube API — which is what YouTube itself uses.", | ||
@@ -58,2 +58,3 @@ "main": "index.js", | ||
"studio", | ||
"upload", | ||
"youtube-studio", | ||
@@ -60,0 +61,0 @@ "innertube", |
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
334283
8405