From ef9a22e85af30edae211097f8d53ed4ec3f44112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kr=C3=A1sn=C3=BD?= <53856821+DanielKrasny@users.noreply.github.com> Date: Tue, 28 Jun 2022 00:15:47 +0200 Subject: [PATCH] feat(ytmusic): multiple video authors (#83) Parse all `authors` from a music video. For legacy reasons, `author` key is kept returning the first entry. Definitions updated respectively. --- lib/parser/contents/classes/MusicResponsiveListItem.js | 6 +++--- .../parser/contents/classes/MusicResponsiveListItem.d.ts | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/parser/contents/classes/MusicResponsiveListItem.js b/lib/parser/contents/classes/MusicResponsiveListItem.js index 40e7301a..50d974b5 100644 --- a/lib/parser/contents/classes/MusicResponsiveListItem.js +++ b/lib/parser/contents/classes/MusicResponsiveListItem.js @@ -104,13 +104,13 @@ class MusicResponsiveListItem { this.views = this.#flex_columns[1].title.runs .find((run) => run.text.match(/(.*?) views/)).text; - const author = this.#flex_columns[1].title.runs.find((run) => run.endpoint.browse?.id.startsWith('UC')); + const authors = this.#flex_columns[1].title.runs?.filter((run) => run.endpoint.browse?.id.startsWith('UC')); - author && (this.author = { + authors && (this.authors = authors.map((author) => ({ name: author.text, channel_id: author.endpoint.browse.id, endpoint: author.endpoint - }); + }))) && (this.author = this.authors[0]); const duration_text = this.#flex_columns[1].title.runs .find((run) => /^\d+$/.test(run.text.replace(/:/g, '')))?.text; diff --git a/typings/lib/parser/contents/classes/MusicResponsiveListItem.d.ts b/typings/lib/parser/contents/classes/MusicResponsiveListItem.d.ts index 6eb1d8b6..ced0584c 100644 --- a/typings/lib/parser/contents/classes/MusicResponsiveListItem.d.ts +++ b/typings/lib/parser/contents/classes/MusicResponsiveListItem.d.ts @@ -37,6 +37,11 @@ declare class MusicResponsiveListItem { channel_id: any; endpoint: any; }; + authors: { + name: any; + channel_id: any; + endpoint: any; + }[]; name: any; subscribers: any; year: any;