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
This commit is contained in:
sebastjanartic 2025-09-02 17:02:40 +00:00
parent 09961bf736
commit 97600c6037

View File

@ -62,46 +62,30 @@ export default function NetflixGrid({ videos, isLoading }: NetflixGridProps) {
videos: folxStadlVideos.slice(0, 12) videos: folxStadlVideos.slice(0, 12)
}] : []), }] : []),
{ {
title: "GDL VIDEO", title: "VIDEO",
videos: (() => { videos: (() => {
// Filter videos that are only Geschichte des Liedes (exclude FOLX STADL and Gipfelstammtisch) // Filter videos that specifically contain "Geschichte des Liedes VIDEO" in title or description
const artistVideos = videos.filter(video => const videoVideos = videos.filter(video =>
!video.title.includes("FOLX STADL") && video.title.toLowerCase().includes("geschichte des liedes video") ||
!video.title.includes("FOLXSTADL") && video.description?.toLowerCase().includes("geschichte des liedes video")
!video.title.includes("Gipfelstammtisch")
); );
// Group by performer/artist (extract performer name before " - ") // If no specific "Geschichte des Liedes VIDEO" videos found, fallback to general filter
const performerGroups: { [key: string]: typeof videos } = {}; if (videoVideos.length === 0) {
artistVideos.forEach(video => { const fallbackVideos = videos.filter(video =>
const performer = video.title.split(" - ")[0] || "Unknown"; !video.title.includes("FOLX STADL") &&
if (!performerGroups[performer]) { !video.title.includes("FOLXSTADL") &&
performerGroups[performer] = []; !video.title.includes("Gipfelstammtisch")
}
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()
); );
}); const shuffled = [...fallbackVideos].sort(() => Math.random() - 0.5);
return shuffled.slice(0, 15);
// 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]);
}
}
} }
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);
})() })()
}, },
{ {