mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-28 00:56:23 +00:00
feat: improve parsing (#145)
* fix: err in `MusicDetailHeader` when no duration * feat: get video duration from more places
This commit is contained in:
@@ -14,7 +14,7 @@ class MusicDetailHeader extends YTNode {
|
||||
this.second_subtitle = new Text(data.secondSubtitle);
|
||||
this.year = this.subtitle.runs.find((run) => (/^[12][0-9]{3}$/).test(run.text))?.text || null;
|
||||
this.song_count = this.second_subtitle.runs[0].text;
|
||||
this.total_duration = this.second_subtitle.runs[2].text;
|
||||
this.total_duration = this.second_subtitle.runs[2]?.text || '';
|
||||
this.thumbnails = Thumbnail.fromResponse(data.thumbnail.croppedSquareThumbnailRenderer.thumbnail);
|
||||
this.badges = Parser.parse(data.subtitleBadges);
|
||||
|
||||
|
||||
@@ -178,7 +178,8 @@ class MusicResponsiveListItem extends YTNode {
|
||||
}));
|
||||
}
|
||||
|
||||
const duration_text = this.#flex_columns[1].key('title').instanceof(Text).runs?.find((run) => (/^\d+$/).test(run.text.replace(/:/g, '')))?.text;
|
||||
const duration_text = this.#flex_columns[1].key('title').instanceof(Text).runs?.find((run) => (/^\d+$/).test(run.text.replace(/:/g, '')))?.text ||
|
||||
this.#fixed_columns[0]?.key('title').instanceof(Text).runs?.find((run) => (/^\d+$/).test(run.text.replace(/:/g, '')))?.text;
|
||||
duration_text && (this.duration = {
|
||||
text: duration_text,
|
||||
seconds: timeToSeconds(duration_text)
|
||||
|
||||
Reference in New Issue
Block a user