From 7684d5d8fa3150cce3464910485f9c2ee553cf56 Mon Sep 17 00:00:00 2001 From: nico-iaco Date: Fri, 4 Jul 2025 16:32:14 +0200 Subject: [PATCH 01/11] Fix issue TypeError: Cannot read properties of undefined (reading 'runs') at Module.get_playlist --- src/mixins/playlist.ts | 2 +- src/parsers/songs.ts | 19 +++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/mixins/playlist.ts b/src/mixins/playlist.ts index 447045a..6e87dec 100644 --- a/src/mixins/playlist.ts +++ b/src/mixins/playlist.ts @@ -179,7 +179,7 @@ export async function get_playlist( thumbnails: j(header, THUMBNAILS), description: jo(header, "description", DESCRIPTION_SHELF, DESCRIPTION), type: run_count > 0 ? j(header, SUBTITLE) : null, - authors: parse_song_artists_runs(header.straplineTextOne.runs), + authors: parse_song_artists_runs(header.straplineTextOne?.runs), year: j(header, "subtitle.runs", (run_count - 1).toString(), "text"), trackCount: secondRuns ? secondRuns[0].text : null, duration: secondRuns && secondRuns.length > 2 ? secondRuns[2].text : null, diff --git a/src/parsers/songs.ts b/src/parsers/songs.ts index 82ac526..4c2eb15 100644 --- a/src/parsers/songs.ts +++ b/src/parsers/songs.ts @@ -115,27 +115,22 @@ export interface ArtistRun { type: "artist" | "channel"; } -export function parse_song_artists_runs(runs: any) { - const artists: ArtistRun[] = []; - const result = Array(Math.floor(runs.length / 2) + 1).fill(undefined).map(( - _, - index, - ) => index); - +export function parse_song_artists_runs(runs) { + if (!runs) + return []; + const artists = []; + const result = Array(Math.floor(runs.length / 2) + 1).fill(undefined).map((_, index) => index); for (const i of result) { const run = runs[i * 2]; - - if (run == null) continue; - + if (run == null) + continue; const page_type = jo(run, NAVIGATION_PAGE_TYPE); - artists.push({ name: run.text, id: jo(run, NAVIGATION_BROWSE_ID), type: page_type === "MUSIC_PAGE_TYPE_ARTIST" ? "artist" : "channel", }); } - return artists; } From b0b37b7219578914c06b7cce8b7b08326aecb921 Mon Sep 17 00:00:00 2001 From: Nicola Iacovelli Date: Sat, 5 Jul 2025 09:54:31 +0200 Subject: [PATCH 02/11] Update src/parsers/songs.ts Co-authored-by: Angelo Verlain Shema <37999241+vixalien@users.noreply.github.com> --- src/parsers/songs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parsers/songs.ts b/src/parsers/songs.ts index 4c2eb15..ae74c87 100644 --- a/src/parsers/songs.ts +++ b/src/parsers/songs.ts @@ -115,7 +115,7 @@ export interface ArtistRun { type: "artist" | "channel"; } -export function parse_song_artists_runs(runs) { +export function parse_song_artists_runs(runs: any) { if (!runs) return []; const artists = []; From edaa200e3c895e72cb565ba69fd5b068065a3c03 Mon Sep 17 00:00:00 2001 From: Nicola Iacovelli Date: Mon, 7 Jul 2025 14:18:33 +0200 Subject: [PATCH 03/11] Update src/parsers/songs.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/parsers/songs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parsers/songs.ts b/src/parsers/songs.ts index ae74c87..f920abc 100644 --- a/src/parsers/songs.ts +++ b/src/parsers/songs.ts @@ -118,7 +118,7 @@ export interface ArtistRun { export function parse_song_artists_runs(runs: any) { if (!runs) return []; - const artists = []; + const artists: ArtistRun[] = []; const result = Array(Math.floor(runs.length / 2) + 1).fill(undefined).map((_, index) => index); for (const i of result) { const run = runs[i * 2]; From 4ca6d5aab8f5ffbcb4680e1b80950cdee1d58dd3 Mon Sep 17 00:00:00 2001 From: Nicola Iacovelli Date: Mon, 7 Jul 2025 18:15:12 +0200 Subject: [PATCH 04/11] Update src/parsers/songs.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/parsers/songs.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/parsers/songs.ts b/src/parsers/songs.ts index f920abc..cd7a6d9 100644 --- a/src/parsers/songs.ts +++ b/src/parsers/songs.ts @@ -116,8 +116,9 @@ export interface ArtistRun { } export function parse_song_artists_runs(runs: any) { - if (!runs) + if (!runs) { return []; + } const artists: ArtistRun[] = []; const result = Array(Math.floor(runs.length / 2) + 1).fill(undefined).map((_, index) => index); for (const i of result) { From f10c713f790127f57b94827cc5c95170b3282078 Mon Sep 17 00:00:00 2001 From: Nicola Iacovelli Date: Mon, 7 Jul 2025 18:15:23 +0200 Subject: [PATCH 05/11] Update src/parsers/songs.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/parsers/songs.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/parsers/songs.ts b/src/parsers/songs.ts index cd7a6d9..c2bec71 100644 --- a/src/parsers/songs.ts +++ b/src/parsers/songs.ts @@ -120,9 +120,8 @@ export function parse_song_artists_runs(runs: any) { return []; } const artists: ArtistRun[] = []; - const result = Array(Math.floor(runs.length / 2) + 1).fill(undefined).map((_, index) => index); - for (const i of result) { - const run = runs[i * 2]; + for (let i = 0; i < runs.length; i += 2) { + const run = runs[i]; if (run == null) continue; const page_type = jo(run, NAVIGATION_PAGE_TYPE); From 38e41b7cf7a991fbc9fcdc467f155f4cbaf53a24 Mon Sep 17 00:00:00 2001 From: Nicola Iacovelli Date: Fri, 18 Jul 2025 11:43:27 +0200 Subject: [PATCH 06/11] Update src/parsers/songs.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/parsers/songs.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/parsers/songs.ts b/src/parsers/songs.ts index c2bec71..0a39f1f 100644 --- a/src/parsers/songs.ts +++ b/src/parsers/songs.ts @@ -115,7 +115,12 @@ export interface ArtistRun { type: "artist" | "channel"; } -export function parse_song_artists_runs(runs: any) { +export interface Run { + text: string; + [key: string]: any; // Allow additional properties for flexibility +} + +export function parse_song_artists_runs(runs: Run[] | undefined) { if (!runs) { return []; } From 4b4dd83799b78e8ab1fc7b5380f70e37f764d1f8 Mon Sep 17 00:00:00 2001 From: Nicola Iacovelli Date: Fri, 18 Jul 2025 11:43:38 +0200 Subject: [PATCH 07/11] Update src/parsers/songs.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/parsers/songs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parsers/songs.ts b/src/parsers/songs.ts index 0a39f1f..5343134 100644 --- a/src/parsers/songs.ts +++ b/src/parsers/songs.ts @@ -121,7 +121,7 @@ export interface Run { } export function parse_song_artists_runs(runs: Run[] | undefined) { - if (!runs) { + if (!Array.isArray(runs)) { return []; } const artists: ArtistRun[] = []; From 6e46fcb5cfb874cbeac92d7976faa69adfd3ac12 Mon Sep 17 00:00:00 2001 From: Nicola Iacovelli Date: Fri, 18 Jul 2025 11:43:48 +0200 Subject: [PATCH 08/11] Update src/parsers/songs.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/parsers/songs.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/parsers/songs.ts b/src/parsers/songs.ts index 5343134..53e505a 100644 --- a/src/parsers/songs.ts +++ b/src/parsers/songs.ts @@ -125,6 +125,7 @@ export function parse_song_artists_runs(runs: Run[] | undefined) { return []; } const artists: ArtistRun[] = []; + // Iterate through every other element in 'runs' because each artist entry is located at even indices. for (let i = 0; i < runs.length; i += 2) { const run = runs[i]; if (run == null) From ef961c703b7d82dcd5b961602e1d4faa4a93144b Mon Sep 17 00:00:00 2001 From: Nicola Iacovelli Date: Fri, 18 Jul 2025 11:47:40 +0200 Subject: [PATCH 09/11] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/parsers/songs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parsers/songs.ts b/src/parsers/songs.ts index 53e505a..06a7d1b 100644 --- a/src/parsers/songs.ts +++ b/src/parsers/songs.ts @@ -121,7 +121,7 @@ export interface Run { } export function parse_song_artists_runs(runs: Run[] | undefined) { - if (!Array.isArray(runs)) { + if (!runs || !Array.isArray(runs)) { return []; } const artists: ArtistRun[] = []; From cd14546f37b3c0b8fea1b88c5417f20756fc3d57 Mon Sep 17 00:00:00 2001 From: Nicola Iacovelli Date: Fri, 18 Jul 2025 11:47:50 +0200 Subject: [PATCH 10/11] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/parsers/songs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parsers/songs.ts b/src/parsers/songs.ts index 06a7d1b..e2506a3 100644 --- a/src/parsers/songs.ts +++ b/src/parsers/songs.ts @@ -128,7 +128,7 @@ export function parse_song_artists_runs(runs: Run[] | undefined) { // Iterate through every other element in 'runs' because each artist entry is located at even indices. for (let i = 0; i < runs.length; i += 2) { const run = runs[i]; - if (run == null) + if (run === null || run === undefined) continue; const page_type = jo(run, NAVIGATION_PAGE_TYPE); artists.push({ From 137f44207158569ea61478582ff4af7084787623 Mon Sep 17 00:00:00 2001 From: Nicola Iacovelli Date: Fri, 18 Jul 2025 11:54:13 +0200 Subject: [PATCH 11/11] final fix --- src/parsers/songs.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/parsers/songs.ts b/src/parsers/songs.ts index e2506a3..107e248 100644 --- a/src/parsers/songs.ts +++ b/src/parsers/songs.ts @@ -115,12 +115,7 @@ export interface ArtistRun { type: "artist" | "channel"; } -export interface Run { - text: string; - [key: string]: any; // Allow additional properties for flexibility -} - -export function parse_song_artists_runs(runs: Run[] | undefined) { +export function parse_song_artists_runs(runs: any) { if (!runs || !Array.isArray(runs)) { return []; }