From a189a60f60e6b1321e7a44db6f44c57003d0ba1d Mon Sep 17 00:00:00 2001 From: sebastjanartic <45803536-sebastjanartic@users.noreply.replit.com> Date: Sat, 6 Sep 2025 19:51:15 +0000 Subject: [PATCH] Add metadata for video content and update sync logic Update BunnyService to include artist, filename, and episode details, and modify VideoSyncService to insert/update these new fields in the database, while also increasing the database sync timeout. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 636b67ca-6f18-4eb7-b992-168c6c8b7078 Replit-Commit-Checkpoint-Type: intermediate_checkpoint --- server/bunny.ts | 6 ++++++ server/videoSync.ts | 15 ++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/server/bunny.ts b/server/bunny.ts index 7161539..e570be0 100644 --- a/server/bunny.ts +++ b/server/bunny.ts @@ -103,7 +103,11 @@ export class BunnyService { return { id: bunnyVideo.guid, title: bunnyVideo.title || 'Untitled Video', + artist: null, // Extract from title if needed 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, customThumbnailUrl: null, videoUrl: hlsUrl, // Signed HLS URL @@ -112,6 +116,8 @@ export class BunnyService { duration: Math.floor(bunnyVideo.length || 0), views: bunnyVideo.views || 0, category: category, + contentType: 'video' as const, + genre: 'other' as const, tags: tags, isPublic: true, uploadStatus: "completed", diff --git a/server/videoSync.ts b/server/videoSync.ts index 6d0a380..ba2bb7a 100644 --- a/server/videoSync.ts +++ b/server/videoSync.ts @@ -116,20 +116,21 @@ class VideoSyncService { }; if (existingVideo.rows.length === 0) { - // Insert new video using raw SQL with all required columns + // Insert new video using raw SQL with all required columns including the new ones await db.execute(sql` - INSERT INTO videos (id, title, description, thumbnail_url, video_url, duration, views, category, custom_thumbnail_url, tags, is_public, content_type, genre, upload_status, created_at, updated_at) - VALUES (${videoData.id}, ${videoData.title}, ${videoData.description}, ${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()}) + 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) + 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()}) `); insertedCount++; } else { - // Update existing video using raw SQL + // Update existing video using raw SQL with all fields await db.execute(sql` UPDATE videos SET title = ${videoData.title}, description = ${videoData.description}, thumbnail_url = ${videoData.thumbnailUrl}, video_url = ${videoData.videoUrl}, duration = ${videoData.duration}, views = ${videoData.views}, 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} `); updatedCount++; @@ -166,9 +167,9 @@ class VideoSyncService { try { await this.syncVideos(); - // Add timeout protection for database sync + // Add timeout protection for database sync - increased to 2 minutes for large datasets const syncTimeout = new Promise((_, reject) => - setTimeout(() => reject(new Error('Database sync timeout after 30 seconds')), 30000) + setTimeout(() => reject(new Error('Database sync timeout after 2 minutes')), 120000) ); await Promise.race([