mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-07-01 20:46:14 +00:00
feat(MediaInfo): Parse player config
This commit is contained in:
@@ -398,6 +398,28 @@ export function parseResponse<T extends IParsedResponse = IParsedResponse>(data:
|
||||
parsed_data.streaming_data = streaming_data;
|
||||
}
|
||||
|
||||
if (data.playerConfig) {
|
||||
const player_config = {
|
||||
audio_config: {
|
||||
loudness_db: data.playerConfig.audioConfig.loudnessDb,
|
||||
perceptual_loudness_db: data.playerConfig.audioConfig.perceptualLoudnessDb,
|
||||
enable_per_format_loudness: data.playerConfig.audioConfig.enablePerFormatLoudness
|
||||
},
|
||||
stream_selection_config: {
|
||||
max_bitrate: data.playerConfig.streamSelectionConfig.maxBitrate
|
||||
},
|
||||
media_common_config: {
|
||||
dynamic_readahead_config: {
|
||||
max_read_ahead_media_time_ms: data.playerConfig.mediaCommonConfig.dynamicReadaheadConfig.maxReadAheadMediaTimeMs,
|
||||
min_read_ahead_media_time_ms: data.playerConfig.mediaCommonConfig.dynamicReadaheadConfig.minReadAheadMediaTimeMs,
|
||||
read_ahead_growth_rate_ms: data.playerConfig.mediaCommonConfig.dynamicReadaheadConfig.readAheadGrowthRateMs
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
parsed_data.player_config = player_config;
|
||||
}
|
||||
|
||||
const current_video_endpoint = data.currentVideoEndpoint ? new NavigationEndpoint(data.currentVideoEndpoint) : null;
|
||||
if (current_video_endpoint) {
|
||||
parsed_data.current_video_endpoint = current_video_endpoint;
|
||||
|
||||
@@ -56,6 +56,7 @@ export interface IParsedResponse {
|
||||
};
|
||||
playability_status?: IPlayabilityStatus;
|
||||
streaming_data?: IStreamingData;
|
||||
player_config?: IPlayerConfig;
|
||||
current_video_endpoint?: NavigationEndpoint;
|
||||
endpoint?: NavigationEndpoint;
|
||||
captions?: PlayerCaptionsTracklist;
|
||||
@@ -71,6 +72,24 @@ export interface IParsedResponse {
|
||||
continuationEndpoint?: YTNode;
|
||||
}
|
||||
|
||||
export interface IPlayerConfig {
|
||||
audio_config: {
|
||||
loudness_db: number;
|
||||
perceptual_loudness_db: number;
|
||||
enable_per_format_loudness: boolean;
|
||||
};
|
||||
stream_selection_config: {
|
||||
max_bitrate: string;
|
||||
};
|
||||
media_common_config: {
|
||||
dynamic_readahead_config: {
|
||||
max_read_ahead_media_time_ms: number;
|
||||
min_read_ahead_media_time_ms: number;
|
||||
read_ahead_growth_rate_ms: number;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export interface IStreamingData {
|
||||
expires: Date;
|
||||
formats: Format[];
|
||||
@@ -87,6 +106,7 @@ export interface IPlayerResponse {
|
||||
annotations?: ObservedArray<PlayerAnnotationsExpanded>;
|
||||
playability_status: IPlayabilityStatus;
|
||||
streaming_data?: IStreamingData;
|
||||
player_config: IPlayerConfig;
|
||||
playback_tracking?: {
|
||||
videostats_watchtime_url: string;
|
||||
videostats_playback_url: string;
|
||||
|
||||
@@ -1,6 +1,24 @@
|
||||
export type RawNode = Record<string, any>;
|
||||
export type RawData = RawNode | RawNode[];
|
||||
|
||||
export interface IRawPlayerConfig {
|
||||
audioConfig: {
|
||||
loudnessDb: number;
|
||||
perceptualLoudnessDb: number;
|
||||
enablePerFormatLoudness: boolean;
|
||||
};
|
||||
streamSelectionConfig: {
|
||||
maxBitrate: string;
|
||||
};
|
||||
mediaCommonConfig: {
|
||||
dynamicReadaheadConfig: {
|
||||
maxReadAheadMediaTimeMs: number;
|
||||
minReadAheadMediaTimeMs: number;
|
||||
readAheadGrowthRateMs: number;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export interface IRawResponse {
|
||||
contents?: RawData;
|
||||
onResponseReceivedActions?: RawNode[];
|
||||
@@ -41,6 +59,7 @@ export interface IRawResponse {
|
||||
dashManifestUrl?: string;
|
||||
hlsManifestUrl?: string;
|
||||
};
|
||||
playerConfig?: IRawPlayerConfig;
|
||||
currentVideoEndpoint?: RawNode;
|
||||
unseenCount?: number;
|
||||
playlistId?: string;
|
||||
|
||||
Reference in New Issue
Block a user