From 169b4b777bd2114eb22fbf0588db186fb8661124 Mon Sep 17 00:00:00 2001 From: sebastjanartic <45803536-sebastjanartic@users.noreply.replit.com> Date: Wed, 3 Sep 2025 10:57:38 +0000 Subject: [PATCH] Improve video sharing by optimizing thumbnails and meta descriptions Update meta description for videos to include title and platform details. Implement logic to fetch and resize actual thumbnails from Bunny.net for social media sharing, using JPEG format for better quality and setting a 2-hour cache. Also, improve video not found error handling and logging. 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/HCAS0JG --- client/src/pages/VideoPage.tsx | 4 ++-- server/routes.ts | 20 +++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/client/src/pages/VideoPage.tsx b/client/src/pages/VideoPage.tsx index 1791674..98e3c4f 100644 --- a/client/src/pages/VideoPage.tsx +++ b/client/src/pages/VideoPage.tsx @@ -157,7 +157,7 @@ export default function VideoPage() { if (metaDescription) { const descriptionContent = currentVideo.description && currentVideo.description.trim() !== '' ? currentVideo.description - : `Schauen Sie sich "${currentVideo.title}" auf go4.video an. Professionelle Video-Streaming-Plattform mit exklusivem Content von FOLX STADL, Geschichte des Liedes und weiteren Premium-Inhalten.`; + : `${currentVideo.title} - Professionelle Video-Streaming-Plattform mit exklusivem Content von FOLX STADL, Geschichte des Liedes und weiteren Premium-Inhalten auf go4.video.`; metaDescription.setAttribute('content', descriptionContent); } @@ -177,7 +177,7 @@ export default function VideoPage() { // Use original description if available, otherwise create rich description const richDescription = currentVideo.description && currentVideo.description.trim() !== '' ? currentVideo.description - : `Schauen Sie sich "${currentVideo.title}" auf go4.video an. Professionelle Video-Streaming-Plattform mit exklusivem Content von FOLX STADL, Geschichte des Liedes und weiteren Premium-Inhalten.`; + : `${currentVideo.title} - Professionelle Video-Streaming-Plattform mit exklusivem Content von FOLX STADL, Geschichte des Liedes und weiteren Premium-Inhalten auf go4.video.`; updateMetaTag('og:description', richDescription); // Get the correct domain dynamically and add cache-busting diff --git a/server/routes.ts b/server/routes.ts index 8ae8bb9..3ffd89c 100644 --- a/server/routes.ts +++ b/server/routes.ts @@ -840,29 +840,35 @@ export async function registerRoutes(app: Express): Promise { const video = await storage.getVideo(videoId); if (!video) { + console.log(`❌ Video not found: ${videoId}`); return res.status(404).send('Video not found'); } - // Uporabimo čisti thumbnail iz Bunny.net + console.log(`🖼️ Generating thumbnail for: ${video.title}`); + + // Uporabimo čisti thumbnail iz Bunny.net - prioriteta if (video.thumbnailUrl) { try { - // Prenesemo dejanski thumbnail iz Bunny.net + console.log(`📥 Fetching thumbnail from Bunny.net: ${video.thumbnailUrl}`); const response = await fetch(video.thumbnailUrl); if (response.ok) { const thumbnailBuffer = await response.arrayBuffer(); - // Preprosto povečamo thumbnail na social media velikost (1200x630) brez overlay-a + // Optimiziramo thumbnail za social media brez overlay-a const resizedBuffer = await sharp(Buffer.from(thumbnailBuffer)) .resize(1200, 630, { fit: 'cover', position: 'center' }) - .png({ quality: 90, compressionLevel: 6 }) + .jpeg({ quality: 85, progressive: true }) // JPEG je bolje za photo thumbnails .toBuffer(); - res.setHeader('Content-Type', 'image/png'); - res.setHeader('Cache-Control', 'public, max-age=3600'); // Cache za 1 uro + console.log(`✅ Real thumbnail processed: ${resizedBuffer.length} bytes`); + + res.setHeader('Content-Type', 'image/jpeg'); + res.setHeader('Cache-Control', 'public, max-age=7200'); // Cache za 2 uri + res.setHeader('Access-Control-Allow-Origin', '*'); return res.send(resizedBuffer); } } catch (fetchError) { - console.log('Failed to fetch real thumbnail, falling back to generated:', fetchError); + console.log('⚠️ Failed to fetch real thumbnail, falling back to generated:', fetchError); } }