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:
parent
09961bf736
commit
97600c6037
@ -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.toLowerCase().includes("geschichte des liedes video") ||
|
||||||
|
video.description?.toLowerCase().includes("geschichte des liedes video")
|
||||||
|
);
|
||||||
|
|
||||||
|
// 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("FOLX STADL") &&
|
||||||
!video.title.includes("FOLXSTADL") &&
|
!video.title.includes("FOLXSTADL") &&
|
||||||
!video.title.includes("Gipfelstammtisch")
|
!video.title.includes("Gipfelstammtisch")
|
||||||
);
|
);
|
||||||
|
const shuffled = [...fallbackVideos].sort(() => Math.random() - 0.5);
|
||||||
// Group by performer/artist (extract performer name before " - ")
|
return shuffled.slice(0, 15);
|
||||||
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()
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 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);
|
||||||
})()
|
})()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user