From 97600c603780a2cd75c79c1de9ef539404ae5547 Mon Sep 17 00:00:00 2001 From: sebastjanartic <45803536-sebastjanartic@users.noreply.replit.com> Date: Tue, 2 Sep 2025 17:02:40 +0000 Subject: [PATCH] Improve video filtering and display logic for specific content Refactors the NetflixGrid component to dynamically filter and display videos, prioritizing content matching "Geschichte des Liedes VIDEO" in title or description, with a fallback to a broader filter and random shuffling. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 2cd2c0bc-434c-4bc9-ad3f-b99d3897a0d1 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/2cd2c0bc-434c-4bc9-ad3f-b99d3897a0d1/4DOsXkx --- client/src/components/netflix-grid.tsx | 52 +++++++++----------------- 1 file changed, 18 insertions(+), 34 deletions(-) diff --git a/client/src/components/netflix-grid.tsx b/client/src/components/netflix-grid.tsx index 566badf..e7ae852 100644 --- a/client/src/components/netflix-grid.tsx +++ b/client/src/components/netflix-grid.tsx @@ -62,46 +62,30 @@ export default function NetflixGrid({ videos, isLoading }: NetflixGridProps) { videos: folxStadlVideos.slice(0, 12) }] : []), { - title: "GDL VIDEO", + title: "VIDEO", videos: (() => { - // Filter videos that are only Geschichte des Liedes (exclude FOLX STADL and Gipfelstammtisch) - const artistVideos = videos.filter(video => - !video.title.includes("FOLX STADL") && - !video.title.includes("FOLXSTADL") && - !video.title.includes("Gipfelstammtisch") + // Filter videos that specifically contain "Geschichte des Liedes VIDEO" in title or description + const videoVideos = videos.filter(video => + video.title.toLowerCase().includes("geschichte des liedes video") || + video.description?.toLowerCase().includes("geschichte des liedes video") ); - // Group by performer/artist (extract performer name before " - ") - const performerGroups: { [key: string]: typeof videos } = {}; - artistVideos.forEach(video => { - const performer = video.title.split(" - ")[0] || "Unknown"; - if (!performerGroups[performer]) { - performerGroups[performer] = []; - } - performerGroups[performer].push(video); - }); - - // Sort each group by upload date (newest first) - Object.keys(performerGroups).forEach(performer => { - performerGroups[performer].sort((a, b) => - new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime() + // If no specific "Geschichte des Liedes VIDEO" videos found, fallback to general filter + if (videoVideos.length === 0) { + const fallbackVideos = videos.filter(video => + !video.title.includes("FOLX STADL") && + !video.title.includes("FOLXSTADL") && + !video.title.includes("Gipfelstammtisch") ); - }); - - // Distribute videos: first one from each performer, then continue - const result = []; - const performers = Object.keys(performerGroups); - let maxRounds = Math.max(...performers.map(p => performerGroups[p].length)); - - for (let round = 0; round < maxRounds && result.length < 15; round++) { - for (let performer of performers) { - if (performerGroups[performer][round] && result.length < 15) { - result.push(performerGroups[performer][round]); - } - } + const shuffled = [...fallbackVideos].sort(() => Math.random() - 0.5); + return shuffled.slice(0, 15); } - return result; + // Shuffle the Geschichte des Liedes VIDEO videos randomly + const shuffled = [...videoVideos].sort(() => Math.random() - 0.5); + + // Return 15 random videos from the VIDEO collection + return shuffled.slice(0, 15); })() }, {