mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-23 23:09:28 +00:00
fix(VideoInfo.ts): reimplement get music_tracks (#409)
* fix(VideoInfo.ts): reimplement `get music_tracks` - Add parser classes to parse needed data - Add `CarouselLockup` - Add `EngagementPanelSectionList` - Add `InfoRow` - Add `StructuredDescriptionContent` - Add `VideoDescriptionMusicSection` - Add `VideoDescriptionHeader` - Add `Factoid` - Add `ExpandableVideoDescriptionBody` - Add `AdsEngagementPanelContent` - Add `engagement_panels` to raw and parsed next responses - Add `engagement_panels` parsing code to `parser.ts` * Check for song inside of video_lockup first before checking info_rows * Add support for pulling artist ids out of music_tracks - Add support for WRITERS InfoRow - Check for video id inside of naviagation endpoint on info_row metadata * Add `AdsEngagementPanelContent` to ignore list * Switch `map => parseItem` to `parseArray` * Use `Text` && `NavigationEndpoint` * Replace `String` with `Text` in `ExpandableVideoDescriptionBody`
This commit is contained in:
38
src/parser/classes/InfoRow.ts
Normal file
38
src/parser/classes/InfoRow.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { YTNode } from '../helpers.js';
|
||||
import Parser, { type RawNode } from '../index.js';
|
||||
import { Text } from '../misc.js';
|
||||
import NavigationEndpoint from './NavigationEndpoint.js';
|
||||
|
||||
export default class InfoRow extends YTNode {
|
||||
static type = 'InfoRow';
|
||||
metadata_text?: Text;
|
||||
metadata_endpoint?: NavigationEndpoint;
|
||||
info_row_expand_status_key: String;
|
||||
title: Text;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
if ('defaultMetadata' in data && 'runs' in data.defaultMetadata) {
|
||||
const runs = data.defaultMetadata.runs;
|
||||
if (runs.length > 0) {
|
||||
const run = runs[0];
|
||||
this.metadata_text = run?.text;
|
||||
if ('navigationEndpoint' in run) {
|
||||
this.metadata_endpoint = Parser.parseItem({ navigationEndpoint: run.navigationEndpoint }, NavigationEndpoint) || undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ('expandedMetadata' in data && 'runs' in data.expandedMetadata) {
|
||||
this.metadata_text = new Text(data.expandedMetadata);
|
||||
}
|
||||
if (this.metadata_text === undefined) {
|
||||
this.metadata_text = data.expandedMetadata?.simpleText
|
||||
? new Text(data.expandedMetadata)
|
||||
: data.defaultMetadata?.simpleText
|
||||
? new Text(data.defaultMetadata)
|
||||
: undefined;
|
||||
}
|
||||
this.info_row_expand_status_key = data.infoRowExpandStatusKey;
|
||||
this.title = new Text(data.title);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user