Restore enhanced video loading functionality in videoLibrary.js

CRITICAL FIX: Restored Unified Video Library System
- Fixed accidental revert that broke video loading in Porn Cinema
- Restored enhanced getAllVideos() method usage instead of broken scanDirectoryForVideos()
- Eliminated ENOENT errors from scanning non-existent local video directories
- Re-implemented robust fallback mechanisms (unified storage  legacy storage)

 FUNCTIONALITY RESTORED
- Videos now load properly from linked external directories (E:\Videos\M1K1)
- Proper access to unified video library with 9 Princess Miki videos
- Enhanced error handling and storage method fallbacks
- Clean console output without directory scanning errors

This resolves the regression where the git revert accidentally removed
the enhanced video loading logic, causing directory scan failures and
preventing videos from loading in the Porn Cinema.
This commit is contained in:
dilgenfritz 2025-10-31 15:10:41 -05:00
parent 77af6076e0
commit 220f347269
1 changed files with 34 additions and 15 deletions

View File

@ -83,25 +83,44 @@ class VideoLibrary {
return;
}
// Get video files from all categories
// Get video files from unified video library
let allVideos = [];
try {
const backgroundVideos = await window.desktopFileManager.scanDirectoryForVideos('background');
const taskVideos = await window.desktopFileManager.scanDirectoryForVideos('tasks');
const rewardVideos = await window.desktopFileManager.scanDirectoryForVideos('rewards');
const punishmentVideos = await window.desktopFileManager.scanDirectoryForVideos('punishments');
if (window.desktopFileManager) {
allVideos = window.desktopFileManager.getAllVideos();
console.log(`📁 Got ${allVideos.length} videos from desktop file manager`);
// If no videos from desktop file manager, try fallback methods
if (allVideos.length === 0) {
console.log('📁 No videos from desktop file manager, trying unified storage...');
// Try unified storage first - read fresh from localStorage to get preserved data
const unifiedData = JSON.parse(localStorage.getItem('unifiedVideoLibrary') || '{}');
allVideos = unifiedData.allVideos || [];
console.log(`📁 Found ${allVideos.length} videos in unified storage`);
// If still no videos, try legacy video storage
if (allVideos.length === 0) {
console.log('📁 No videos in unified storage, trying legacy videoFiles...');
const storedVideos = JSON.parse(localStorage.getItem('videoFiles') || '{}');
allVideos = Object.values(storedVideos).flat();
console.log(`📁 Found ${allVideos.length} videos in legacy storage`);
} else {
console.log('📁 Using videos from unified storage, skipping legacy check');
}
} else {
console.log('📁 Using videos from desktop file manager');
}
} else {
// Fallback to unified storage
const unifiedData = JSON.parse(localStorage.getItem('unifiedVideoLibrary') || '{}');
allVideos = unifiedData.allVideos || [];
}
allVideos = [
...backgroundVideos,
...taskVideos,
...rewardVideos,
...punishmentVideos
];
console.log(`📁 Found ${allVideos.length} videos total`);
console.log(`📁 Found ${allVideos.length} videos total (unified library)`);
} catch (error) {
console.error('Error scanning video directories:', error);
console.error('Error loading video library:', error);
// Fallback to localStorage
const storedVideos = JSON.parse(localStorage.getItem('videoFiles') || '{}');
@ -111,7 +130,7 @@ class VideoLibrary {
}
if (!allVideos || allVideos.length === 0) {
console.log('No videos found');
console.log('No videos found in any storage method');
this.displayEmptyLibrary('No videos found. Upload some videos first!');
return;
}