mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-23 23:09:28 +00:00
feat: wrap format arrays around proxy trap
This allows users to easily find a format.
Ex:
```js
info.streaming_data.adaptive_formats.get({ quality_label: "720p" });
```
This commit is contained in:
@@ -38,7 +38,7 @@ class Parser {
|
||||
on_response_received_endpoints: data.onResponseReceivedEndpoints && Parser.parseRR(data.onResponseReceivedEndpoints) || null,
|
||||
on_response_received_commands: data.onResponseReceivedCommands && Parser.parseRR(data.onResponseReceivedCommands) || null,
|
||||
/** @type {*} */
|
||||
continuation_contents: data.continuationContents && Parser.parseCC(data.continuationContents) || null,
|
||||
continuation_contents: data.continuationContents && Parser.parseLC(data.continuationContents) || null,
|
||||
metadata: Parser.parse(data.metadata),
|
||||
header: Parser.parse(data.header),
|
||||
/** @type {import('./classes/PlayerMicroformat')} **/
|
||||
@@ -77,7 +77,7 @@ class Parser {
|
||||
}
|
||||
}
|
||||
|
||||
static parseCC(data) {
|
||||
static parseLC(data) {
|
||||
if (data.sectionListContinuation)
|
||||
return new SectionListContinuation(data.sectionListContinuation);
|
||||
}
|
||||
@@ -92,7 +92,7 @@ class Parser {
|
||||
}
|
||||
|
||||
static parseFormats(formats) {
|
||||
return formats?.map((format) => new Format(format)) || [];
|
||||
return observe(formats?.map((format) => new Format(format)) || []);
|
||||
}
|
||||
|
||||
static parse(data) {
|
||||
@@ -106,7 +106,7 @@ class Parser {
|
||||
const keys = Object.keys(item);
|
||||
const classname = this.sanitizeClassName(keys[0]);
|
||||
|
||||
if (!this.shouldIgnore(classname)) {
|
||||
if (this.shouldIgnore(classname)) {
|
||||
try {
|
||||
const TargetClass = require('./classes/' + classname);
|
||||
results.push(new TargetClass(item[keys[0]]));
|
||||
|
||||
Reference in New Issue
Block a user