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:
LuanRT
2022-06-14 19:42:44 -03:00
parent 3d0b217743
commit 7e6f944a4b

View File

@@ -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]]));