mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-19 20:41:17 +00:00
refactor: Clean up & fix old code
Other changes: - Renamed "getShortsWatchItem" to "getShortsVideoInfo". - Fixed `ShortFormVideoInfo`. This never worked for me ever since it was introduced. Turned out it was just implemented incorrectly. - Moved `basic_info` extraction to `MediaInfo`. Less of a pain to maintain as we only have to modify one file. - Removed unneeded tsdoc comments. - Fixed `Innertube#getStreamingData()`. Now it actually returns a deciphered format. - Simplified some types.
This commit is contained in:
@@ -311,14 +311,6 @@ export function parseResponse<T extends IParsedResponse = IParsedResponse>(data:
|
||||
}
|
||||
_clearMemo();
|
||||
|
||||
_createMemo();
|
||||
const entries = parse(data.entries);
|
||||
if (entries) {
|
||||
parsed_data.entries = entries;
|
||||
parsed_data.entries_memo = _getMemo();
|
||||
}
|
||||
_clearMemo();
|
||||
|
||||
applyMutations(contents_memo, data.frameworkUpdates?.entityBatchUpdate?.mutations);
|
||||
|
||||
if (on_response_received_endpoints_memo) {
|
||||
@@ -481,6 +473,29 @@ export function parseResponse<T extends IParsedResponse = IParsedResponse>(data:
|
||||
parsed_data.engagement_panels = engagement_panels;
|
||||
}
|
||||
|
||||
if (data.playerResponse) {
|
||||
const player_response = parseResponse(data.playerResponse);
|
||||
parsed_data.player_response = player_response;
|
||||
}
|
||||
|
||||
if (data.watchNextResponse) {
|
||||
const watch_next_response = parseResponse(data.watchNextResponse);
|
||||
parsed_data.watch_next_response = watch_next_response;
|
||||
}
|
||||
|
||||
if (data.cpnInfo) {
|
||||
const cpn_info = {
|
||||
cpn: data.cpnInfo.cpn,
|
||||
cpn_source: data.cpnInfo.cpnSource
|
||||
};
|
||||
|
||||
parsed_data.cpn_info = cpn_info;
|
||||
}
|
||||
|
||||
if (data.entries) {
|
||||
parsed_data.entries = data.entries.map((entry) => new NavigationEndpoint(entry));
|
||||
}
|
||||
|
||||
return parsed_data;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user