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:
sebastjanartic 2025-09-06 19:51:15 +00:00
parent 56a23b142a
commit a189a60f60
2 changed files with 14 additions and 7 deletions

View File

@ -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",

View File

@ -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([