Improve video categorization and ad loading logic

Update filtering for specific video categories like "FOLX STADL" and "GIPFELSTAMMTISCH" to include more variations and improve AdSense ad loading by checking container dimensions before initialization. Also, disable auto-refresh on error.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 636b67ca-6f18-4eb7-b992-168c6c8b7078
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/60d372ff-2c10-46c7-b01b-10c3435136b0/636b67ca-6f18-4eb7-b992-168c6c8b7078/DuqMKeH
This commit is contained in:
sebastjanartic 2025-09-06 20:02:23 +00:00
parent d4d55730e8
commit 5af5e422ec
3 changed files with 46 additions and 22 deletions

View File

@ -19,13 +19,26 @@ export default function AdSenseAd({
useEffect(() => {
try {
// Ensure adsbygoogle is loaded
if (typeof window !== 'undefined') {
// @ts-ignore
(window.adsbygoogle = window.adsbygoogle || []).push({});
// Only initialize if the ad container has proper dimensions
if (typeof window !== 'undefined' && adRef.current) {
const adContainer = adRef.current;
const rect = adContainer.getBoundingClientRect();
// Wait for proper dimensions before initializing
if (rect.width > 0 && rect.height > 0) {
// Small delay to ensure DOM is fully ready
setTimeout(() => {
try {
// @ts-ignore
(window.adsbygoogle = window.adsbygoogle || []).push({});
} catch (error) {
console.warn('AdSense initialization skipped:', error);
}
}, 100);
}
}
} catch (error) {
console.error('AdSense initialization error:', error);
console.warn('AdSense initialization error:', error);
}
}, []);

View File

@ -49,10 +49,15 @@ export default function NetflixGrid({ videos, isLoading }: NetflixGridProps) {
new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
);
// FOLX STADL videos
const folxStadlVideos = videos.filter(video =>
video.title.includes("FOLX STADL") || video.title.includes("FOLXSTADL")
);
// FOLX STADL videos - updated patterns to catch more variations
const folxStadlVideos = videos.filter(video => {
const title = video.title.toLowerCase();
return title.includes("folx stadl") ||
title.includes("folxstadl") ||
title.includes("folx-stadl") ||
title.includes("volx stadl") ||
title.includes("folx_stadl");
});
return [
{
@ -100,10 +105,13 @@ export default function NetflixGrid({ videos, isLoading }: NetflixGridProps) {
{
title: "GIPFELSTAMMTISCH",
videos: (() => {
// Filter videos that specifically contain "Gipfelstammtisch" in title
const gipfelVideos = videos.filter(video =>
video.title.includes("Gipfelstammtisch")
);
// Filter videos that contain "Gipfelstammtisch" in various forms
const gipfelVideos = videos.filter(video => {
const title = video.title.toLowerCase();
return title.includes("gipfelstammtisch") ||
title.includes("gipfel stammtisch") ||
title.includes("gipfel-stammtisch");
});
// Shuffle the Gipfelstammtisch videos randomly
const shuffled = [...gipfelVideos].sort(() => Math.random() - 0.5);
@ -115,11 +123,16 @@ export default function NetflixGrid({ videos, isLoading }: NetflixGridProps) {
{
title: "DIE Geschichte des Liedes",
videos: (() => {
// Filter videos that specifically contain "Geschichte des Liedes" in title or description
const gdlVideos = videos.filter(video =>
video.title.toLowerCase().includes("geschichte des liedes") ||
video.description?.toLowerCase().includes("geschichte des liedes")
);
// Filter videos that contain "Geschichte des Liedes" in various forms
const gdlVideos = videos.filter(video => {
const title = video.title.toLowerCase();
const desc = video.description?.toLowerCase() || "";
return title.includes("geschichte des liedes") ||
title.includes("gschichte des liedes") ||
title.includes("die geschichte des liedes") ||
desc.includes("geschichte des liedes") ||
desc.includes("gschichte des liedes");
});
// If no specific "Geschichte des Liedes" videos found, fallback to general filter
if (gdlVideos.length === 0) {

View File

@ -80,10 +80,8 @@ function initApp() {
</div>
`;
// Auto-refresh on error
setTimeout(() => {
location.reload();
}, 3000);
// Remove auto-refresh to prevent loops
console.warn('Auto-refresh disabled to prevent reload loops');
}
}
}