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:
Emma
2023-06-28 05:54:55 -04:00
committed by GitHub
parent a11e5962c6
commit e434bb2632
13 changed files with 240 additions and 36 deletions

View File

@@ -0,0 +1,29 @@
import { type ObservedArray, YTNode } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Text } from '../misc.js';
import type { Thumbnail } from '../misc.js';
import Factoid from './Factoid.js';
import NavigationEndpoint from './NavigationEndpoint.js';
export default class VideoDescriptionHeader extends YTNode {
static type = 'VideoDescriptionHeader';
channel: Text;
channel_navigation_endpoint?: NavigationEndpoint;
channel_thumbnails: String[];
factoids: ObservedArray<Factoid>;
publish_date: Text;
title: Text;
views: Text;
constructor(data: RawNode) {
super();
this.title = new Text(data.title);
this.channel = new Text(data.channel);
this.channel_navigation_endpoint = Parser.parseItem(data.channelNavigationEndpoint, NavigationEndpoint) || undefined;
this.channel_thumbnails = data.channelThumbnail.thumbnails.map((thumbnail: Thumbnail) => thumbnail.url);
this.publish_date = new Text(data.publishDate);
this.views = new Text(data.views);
this.factoids = Parser.parseArray(data.factoid, Factoid);
}
}