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:
+13
-7
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user