Restored to 'e1314807be287b395cffa7ada2c736a4a7831e11'

Replit-Restored-To: e1314807be
This commit is contained in:
sebastjanartic 2025-09-06 20:11:43 +00:00
parent e4c0b8e5ad
commit e0a31bba5c
5 changed files with 56 additions and 78 deletions

View File

@ -19,26 +19,13 @@ export default function AdSenseAd({
useEffect(() => { useEffect(() => {
try { try {
// Only initialize if the ad container has proper dimensions // Ensure adsbygoogle is loaded
if (typeof window !== 'undefined' && adRef.current) { if (typeof window !== 'undefined') {
const adContainer = adRef.current; // @ts-ignore
const rect = adContainer.getBoundingClientRect(); (window.adsbygoogle = window.adsbygoogle || []).push({});
// 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) { } catch (error) {
console.warn('AdSense initialization error:', error); console.error('AdSense initialization error:', error);
} }
}, []); }, []);

View File

@ -49,35 +49,24 @@ export default function NetflixGrid({ videos, isLoading }: NetflixGridProps) {
new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime() new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
); );
// FOLX STADL videos - match the actual show format // FOLX STADL videos
const folxStadlVideos = videos.filter(video => { const folxStadlVideos = videos.filter(video =>
const title = video.title.toLowerCase(); video.title.includes("FOLX STADL") || video.title.includes("FOLXSTADL")
return title.includes("folx stadl s4") || );
title.includes("folx stadl s3") ||
title.includes("folx stadl s2") ||
title.includes("folx stadl s1") ||
title.includes("folx stadl") ||
title.includes("folxstadl");
});
return [ return [
{ {
title: "Meist Angesehen", title: "Meist Angesehen",
videos: sortedByViews.slice(0, 10) videos: sortedByViews.slice(0, 10)
}, },
{ ...(folxStadlVideos.length > 0 ? [{
title: "FOLX STADL", title: "FOLX STADL",
videos: (() => { videos: (() => {
// Show FOLX STADL episodes in order (newest first) // Shuffle FOLX STADL videos randomly
const sortedFolxStadl = [...folxStadlVideos].sort((a, b) => { const shuffled = [...folxStadlVideos].sort(() => Math.random() - 0.5);
// Extract episode numbers for proper sorting return shuffled.slice(0, 10);
const aEp = parseInt(a.title.match(/\d+/)?.[0] || '0');
const bEp = parseInt(b.title.match(/\d+/)?.[0] || '0');
return bEp - aEp; // Newest episodes first
});
return sortedFolxStadl.slice(0, 10);
})() })()
}, }] : []),
{ {
title: "VIDEO", title: "VIDEO",
videos: (() => { videos: (() => {
@ -111,37 +100,44 @@ export default function NetflixGrid({ videos, isLoading }: NetflixGridProps) {
{ {
title: "GIPFELSTAMMTISCH", title: "GIPFELSTAMMTISCH",
videos: (() => { videos: (() => {
// Filter actual Gipfelstammtisch show episodes // Filter videos that specifically contain "Gipfelstammtisch" in title
const gipfelVideos = videos.filter(video => { const gipfelVideos = videos.filter(video =>
const title = video.title.toLowerCase(); video.title.includes("Gipfelstammtisch")
return title.includes("gipfelstammtisch") && );
!title.includes("folx stadl"); // Exclude if it's part of Folx Stadl
});
// Shuffle the Gipfelstammtisch videos // Shuffle the Gipfelstammtisch videos randomly
const shuffled = [...gipfelVideos].sort(() => Math.random() - 0.5); const shuffled = [...gipfelVideos].sort(() => Math.random() - 0.5);
return shuffled.slice(0, 10);
})()
},
{
title: "DIE GESCHICHTE DES LIEDES",
videos: (() => {
// Filter actual "Die Geschichte des Liedes" episodes
const gdlVideos = videos.filter(video => {
const title = video.title.toLowerCase();
return title.includes("die geschichte des liedes") &&
!title.includes("folx stadl") &&
!title.includes("gipfelstammtisch");
});
// Shuffle the Geschichte des Liedes videos // Return 10 random videos from the GIPFELSTAMMTISCH collection
const shuffled = [...gdlVideos].sort(() => Math.random() - 0.5);
return shuffled.slice(0, 10); return shuffled.slice(0, 10);
})() })()
}, },
{ {
title: "NEUE VIDEOS", title: "DIE Geschichte des Liedes",
videos: sortedByDate.slice(0, 10) 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")
);
// If no specific "Geschichte des Liedes" videos found, fallback to general filter
if (gdlVideos.length === 0) {
const fallbackVideos = videos.filter(video =>
!video.title.includes("FOLX STADL") &&
!video.title.includes("FOLXSTADL") &&
!video.title.includes("Gipfelstammtisch")
);
const shuffled = [...fallbackVideos].sort(() => Math.random() - 0.5);
return shuffled.slice(0, 10);
}
// Shuffle the Geschichte des Liedes videos randomly
const shuffled = [...gdlVideos].sort(() => Math.random() - 0.5);
// Return 10 random videos from the collection
return shuffled.slice(0, 10);
})()
} }
]; ];
}, [videos]); }, [videos]);

View File

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

View File

@ -103,11 +103,7 @@ export class BunnyService {
return { return {
id: bunnyVideo.guid, id: bunnyVideo.guid,
title: bunnyVideo.title || 'Untitled Video', title: bunnyVideo.title || 'Untitled Video',
artist: null, // Extract from title if needed
description: description, description: description,
filename: bunnyVideo.title || null, // Use title as filename fallback
episodeNumber: null, // Parse from title if format detected
episodeTitle: null, // Parse from title if format detected
thumbnailUrl, thumbnailUrl,
customThumbnailUrl: null, customThumbnailUrl: null,
videoUrl: hlsUrl, // Signed HLS URL videoUrl: hlsUrl, // Signed HLS URL
@ -116,8 +112,6 @@ export class BunnyService {
duration: Math.floor(bunnyVideo.length || 0), duration: Math.floor(bunnyVideo.length || 0),
views: bunnyVideo.views || 0, views: bunnyVideo.views || 0,
category: category, category: category,
contentType: 'video' as const,
genre: 'other' as const,
tags: tags, tags: tags,
isPublic: true, isPublic: true,
uploadStatus: "completed", uploadStatus: "completed",

View File

@ -116,21 +116,20 @@ class VideoSyncService {
}; };
if (existingVideo.rows.length === 0) { if (existingVideo.rows.length === 0) {
// Insert new video using raw SQL with all required columns including the new ones // Insert new video using raw SQL to avoid schema issues
await db.execute(sql` await db.execute(sql`
INSERT INTO videos (id, title, artist, description, filename, episode_number, episode_title, thumbnail_url, video_url, duration, views, category, custom_thumbnail_url, tags, is_public, content_type, genre, upload_status, created_at, updated_at) INSERT INTO videos (id, title, description, thumbnail_url, video_url, duration, views, category, custom_thumbnail_url, tags, is_public, created_at, updated_at)
VALUES (${videoData.id}, ${videoData.title}, NULL, ${videoData.description}, ${videoData.title}, NULL, NULL, ${videoData.thumbnailUrl}, ${videoData.videoUrl}, ${videoData.duration}, ${videoData.views}, ${videoData.category}, ${videoData.customThumbnailUrl}, ${'{' + videoData.tags.join(',') + '}'}, ${videoData.isPublic}, 'video', 'other', 'completed', ${videoData.createdAt.toISOString()}, ${videoData.updatedAt.toISOString()}) VALUES (${videoData.id}, ${videoData.title}, ${videoData.description}, ${videoData.thumbnailUrl}, ${videoData.videoUrl}, ${videoData.duration}, ${videoData.views}, ${videoData.category}, ${videoData.customThumbnailUrl}, ${'{' + videoData.tags.join(',') + '}'}, ${videoData.isPublic}, ${videoData.createdAt.toISOString()}, ${videoData.updatedAt.toISOString()})
`); `);
insertedCount++; insertedCount++;
} else { } else {
// Update existing video using raw SQL with all fields // Update existing video using raw SQL
await db.execute(sql` await db.execute(sql`
UPDATE videos UPDATE videos
SET title = ${videoData.title}, description = ${videoData.description}, thumbnail_url = ${videoData.thumbnailUrl}, SET title = ${videoData.title}, description = ${videoData.description}, thumbnail_url = ${videoData.thumbnailUrl},
video_url = ${videoData.videoUrl}, duration = ${videoData.duration}, views = ${videoData.views}, video_url = ${videoData.videoUrl}, duration = ${videoData.duration}, views = ${videoData.views},
category = ${videoData.category}, custom_thumbnail_url = ${videoData.customThumbnailUrl}, category = ${videoData.category}, custom_thumbnail_url = ${videoData.customThumbnailUrl},
tags = ${'{' + videoData.tags.join(',') + '}'}, is_public = ${videoData.isPublic}, updated_at = ${videoData.updatedAt.toISOString()}, tags = ${'{' + videoData.tags.join(',') + '}'}, is_public = ${videoData.isPublic}, updated_at = ${videoData.updatedAt.toISOString()}
artist = NULL, filename = ${videoData.title}, episode_number = NULL, episode_title = NULL
WHERE id = ${video.id} WHERE id = ${video.id}
`); `);
updatedCount++; updatedCount++;
@ -167,9 +166,9 @@ class VideoSyncService {
try { try {
await this.syncVideos(); await this.syncVideos();
// Add timeout protection for database sync - increased to 2 minutes for large datasets // Add timeout protection for database sync
const syncTimeout = new Promise((_, reject) => const syncTimeout = new Promise((_, reject) =>
setTimeout(() => reject(new Error('Database sync timeout after 2 minutes')), 120000) setTimeout(() => reject(new Error('Database sync timeout after 30 seconds')), 30000)
); );
await Promise.race([ await Promise.race([