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
This commit is contained in:
parent
cdb43e1ff2
commit
169b4b777b
@ -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
|
||||
|
||||
@ -840,29 +840,35 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user