mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-19 04:21:35 +00:00
refactor: clean up parser and tests (#387)
* tests: improve coverage * refactor: clean up nodes * chore: lint * feat(parser): ignore `BrandVideoShelf` Seems to be used for ads. * feat(parser): ignore `BrandVideoSingleton` too
This commit is contained in:
@@ -1,22 +1,23 @@
|
||||
import { YTNode } from '../helpers.js';
|
||||
import type { RawNode } from '../index.js';
|
||||
import Text from './misc/Text.js';
|
||||
import Thumbnail from './misc/Thumbnail.js';
|
||||
import { YTNode } from '../helpers.js';
|
||||
|
||||
class PlayerMicroformat extends YTNode {
|
||||
export default class PlayerMicroformat extends YTNode {
|
||||
static type = 'PlayerMicroformat';
|
||||
|
||||
title: Text;
|
||||
description: Text;
|
||||
thumbnails;
|
||||
|
||||
embed: {
|
||||
embed?: {
|
||||
iframe_url: string;
|
||||
flash_url: string;
|
||||
flash_secure_url: string;
|
||||
// TODO: check these
|
||||
width: any;
|
||||
height: any;
|
||||
} | null;
|
||||
};
|
||||
|
||||
length_seconds: number;
|
||||
|
||||
@@ -36,13 +37,13 @@ class PlayerMicroformat extends YTNode {
|
||||
available_countries: string[];
|
||||
start_timestamp: Date | null;
|
||||
|
||||
constructor(data: any) {
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.title = new Text(data.title);
|
||||
this.description = new Text(data.description);
|
||||
this.thumbnails = Thumbnail.fromResponse(data.thumbnail);
|
||||
|
||||
if (data.embed) {
|
||||
if (Reflect.has(data, 'embed')) {
|
||||
this.embed = {
|
||||
iframe_url: data.embed.iframeUrl,
|
||||
flash_url: data.embed.flashUrl,
|
||||
@@ -50,8 +51,6 @@ class PlayerMicroformat extends YTNode {
|
||||
width: data.embed.width,
|
||||
height: data.embed.height
|
||||
};
|
||||
} else {
|
||||
this.embed = null;
|
||||
}
|
||||
|
||||
this.length_seconds = parseInt(data.lengthSeconds);
|
||||
@@ -72,6 +71,4 @@ class PlayerMicroformat extends YTNode {
|
||||
this.available_countries = data.availableCountries;
|
||||
this.start_timestamp = data.liveBroadcastDetails?.startTimestamp ? new Date(data.liveBroadcastDetails.startTimestamp) : null;
|
||||
}
|
||||
}
|
||||
|
||||
export default PlayerMicroformat;
|
||||
}
|
||||
Reference in New Issue
Block a user