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.
This commit is contained in:
Daniel Krásný
2022-06-28 00:15:47 +02:00
committed by GitHub
parent 8849a01ecf
commit ef9a22e85a
2 changed files with 8 additions and 3 deletions

View File

@@ -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;

View File

@@ -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;