Restored to '44d6f571a5a2b8bce0fd4e8a9eae76204284885b'
Replit-Restored-To: 44d6f571a5
This commit is contained in:
+5
-29
@@ -1,5 +1,4 @@
|
||||
import { type Video, type InsertVideo } from "@shared/schema";
|
||||
import crypto from 'crypto';
|
||||
|
||||
interface BunnyVideo {
|
||||
guid: string;
|
||||
@@ -154,23 +153,7 @@ export class BunnyService {
|
||||
console.log(`Fetching video with description from Bunny: ${guid}`);
|
||||
const bunnyVideo: BunnyVideoDetails = await this.makeRequest(`videos/${guid}`);
|
||||
console.log(`Fetching video: ${bunnyVideo.title} - Description available: ${!!bunnyVideo.description}`);
|
||||
// Use direct iframe URL instead of signed URL to avoid complexity
|
||||
return {
|
||||
id: bunnyVideo.guid,
|
||||
title: bunnyVideo.title,
|
||||
description: bunnyVideo.description || "",
|
||||
thumbnailUrl: this.getThumbnailUrl(bunnyVideo.guid, bunnyVideo.thumbnailFileName),
|
||||
videoUrl: `https://iframe.mediadelivery.net/embed/384105/${bunnyVideo.guid}`,
|
||||
duration: bunnyVideo.length,
|
||||
views: bunnyVideo.views,
|
||||
category: bunnyVideo.category || "",
|
||||
tags: bunnyVideo.metaTags?.map(tag => tag.value) || [],
|
||||
isPublic: bunnyVideo.status === 4,
|
||||
uploadStatus: bunnyVideo.status === 4 ? "completed" : "processing",
|
||||
originalFileName: bunnyVideo.title,
|
||||
createdAt: new Date(bunnyVideo.dateUploaded),
|
||||
updatedAt: new Date(bunnyVideo.dateUploaded),
|
||||
};
|
||||
return this.bunnyVideoToVideo(bunnyVideo);
|
||||
} catch (error) {
|
||||
console.error(`Error fetching video ${guid} from Bunny:`, error);
|
||||
return null;
|
||||
@@ -237,19 +220,12 @@ export class BunnyService {
|
||||
|
||||
// Generate signed URL for private video access
|
||||
generateSignedUrl(videoId: string, expirationTime: number = 3600): string {
|
||||
// Use the pull zone hostname for video streaming
|
||||
const baseUrl = `https://${this.hostname}/${videoId}/playlist.m3u8`;
|
||||
const expires = Math.floor(Date.now() / 1000) + expirationTime;
|
||||
|
||||
// Generate security token using library ID and API key
|
||||
const securityKey = this.apiKey;
|
||||
const hashableBase = securityKey + videoId + expires.toString();
|
||||
// Simple token generation (in production, use proper HMAC signing)
|
||||
const token = Buffer.from(`${videoId}:${expires}:${this.apiKey.substring(0, 8)}`).toString('base64');
|
||||
|
||||
// Create a simple hash for the token
|
||||
const hash = crypto.createHash('md5').update(hashableBase).digest('hex');
|
||||
|
||||
return `${baseUrl}?token=${hash}&expires=${expires}`;
|
||||
return `${baseUrl}?token=${token}&expires=${expires}`;
|
||||
}
|
||||
}
|
||||
|
||||
export const bunnyService = new BunnyService();
|
||||
}
|
||||
Reference in New Issue
Block a user