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:
parent
56a23b142a
commit
a189a60f60
@ -103,7 +103,11 @@ export class BunnyService {
|
|||||||
return {
|
return {
|
||||||
id: bunnyVideo.guid,
|
id: bunnyVideo.guid,
|
||||||
title: bunnyVideo.title || 'Untitled Video',
|
title: bunnyVideo.title || 'Untitled Video',
|
||||||
|
artist: null, // Extract from title if needed
|
||||||
description: description,
|
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,
|
thumbnailUrl,
|
||||||
customThumbnailUrl: null,
|
customThumbnailUrl: null,
|
||||||
videoUrl: hlsUrl, // Signed HLS URL
|
videoUrl: hlsUrl, // Signed HLS URL
|
||||||
@ -112,6 +116,8 @@ export class BunnyService {
|
|||||||
duration: Math.floor(bunnyVideo.length || 0),
|
duration: Math.floor(bunnyVideo.length || 0),
|
||||||
views: bunnyVideo.views || 0,
|
views: bunnyVideo.views || 0,
|
||||||
category: category,
|
category: category,
|
||||||
|
contentType: 'video' as const,
|
||||||
|
genre: 'other' as const,
|
||||||
tags: tags,
|
tags: tags,
|
||||||
isPublic: true,
|
isPublic: true,
|
||||||
uploadStatus: "completed",
|
uploadStatus: "completed",
|
||||||
|
|||||||
@ -116,20 +116,21 @@ class VideoSyncService {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (existingVideo.rows.length === 0) {
|
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`
|
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)
|
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}, ${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()})
|
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++;
|
insertedCount++;
|
||||||
} else {
|
} else {
|
||||||
// Update existing video using raw SQL
|
// Update existing video using raw SQL with all fields
|
||||||
await db.execute(sql`
|
await db.execute(sql`
|
||||||
UPDATE videos
|
UPDATE videos
|
||||||
SET title = ${videoData.title}, description = ${videoData.description}, thumbnail_url = ${videoData.thumbnailUrl},
|
SET title = ${videoData.title}, description = ${videoData.description}, thumbnail_url = ${videoData.thumbnailUrl},
|
||||||
video_url = ${videoData.videoUrl}, duration = ${videoData.duration}, views = ${videoData.views},
|
video_url = ${videoData.videoUrl}, duration = ${videoData.duration}, views = ${videoData.views},
|
||||||
category = ${videoData.category}, custom_thumbnail_url = ${videoData.customThumbnailUrl},
|
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}
|
WHERE id = ${video.id}
|
||||||
`);
|
`);
|
||||||
updatedCount++;
|
updatedCount++;
|
||||||
@ -166,9 +167,9 @@ class VideoSyncService {
|
|||||||
try {
|
try {
|
||||||
await this.syncVideos();
|
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) =>
|
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([
|
await Promise.race([
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user