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
This commit is contained in:
+8
-7
@@ -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([
|
||||
|
||||
Reference in New Issue
Block a user