From fa8b3552fdc58be4f4a22b266642a27f85017027 Mon Sep 17 00:00:00 2001 From: jeffvli Date: Fri, 8 Apr 2022 18:47:14 -0700 Subject: [PATCH] Add invalid entry filtering at song dispatch --- src/shared/utils.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/shared/utils.ts b/src/shared/utils.ts index 3f08ad4..9fd1e44 100644 --- a/src/shared/utils.ts +++ b/src/shared/utils.ts @@ -473,17 +473,27 @@ export const getTheme = (themes: any[], value: string) => { export const filterPlayQueue = (filters: any[], entries: any) => { const enabledFilters = filters.filter((f: any) => f.enabled === true); const joinedFilterRegex = enabledFilters.map((f: any) => f.filter).join('|'); + + // Remove invalid songs that may break the player (likely due to Airsonic including folders) + const validEntries = entries.filter((song: any) => { + return song.bitRate && song.duration; + }); + if (joinedFilterRegex) { - const filteredEntries = entries.filter((entry: any) => !entry.title.match(joinedFilterRegex)); + const filteredEntries = validEntries.filter( + (entry: any) => !entry.title.match(joinedFilterRegex) + ); return { entries: filteredEntries, - count: { original: entries.length, filtered: filteredEntries.length }, + count: { original: entries.length, filtered: validEntries.length }, }; } - return { entries, count: { original: entries.length, filtered: entries.length } }; + return { + entries: validEntries, + count: { original: entries.length, filtered: validEntries.length }, + }; }; - export const getPlayedSongsNotification = (options: { original: number; filtered: number;