Backend: People & Media

- Added people manager
- Auto update non fully fetched people
- People media downloader
- Updated media controller to serve peoples profiles
- Config people media folders auto creation
This commit is contained in:
X4Lo committed 2025-07-12 02:54:18 +01:00
1 parent 367c9899a0
commit 9d8f2899d4
6 files changed
+120 -10

No files matched your search

+29 -2
View File
@@ -49,6 +49,35 @@ class MediaDownloaderService {
return downloadedImages;
}
async downloadPersonMedia(person) {
if (!person) return null;
// Local variables for this function invocation
let downloadTasks = [];
let downloadedImages = [];
_configService.createMediaFolders(); // Ensuring directories exist
const dataPath = _configService.getSettings().userDataPath;
// Check if person already has a profile image
const hasProfile = person.medias && person.medias.filter((m) => m.type === 'profile').length !== 0;
if (person.profile_path && !hasProfile) {
const profilesDir = path.join(dataPath, 'images', 'peoples', 'profiles');
this.scheduleDownloads({ file_path: person.profile_path }, 'profile', profilesDir, downloadTasks, downloadedImages);
}
// Wait for all downloads to complete
await Promise.all(downloadTasks).then(() => {
console.log('Downloaded images:', downloadedImages);
}).catch(err => {
console.error('Error downloading entry images:', err);
});
return downloadedImages;
}
// Utility to find the preferred media (English if available, otherwise the first one)
findPreferredMedia(mediaArray, preferredLanguage = 'en') {
return mediaArray.find(media => media.iso_639_1 === preferredLanguage && !media.file_path.includes('.svg')) || mediaArray.find(media => !media.file_path.includes('.svg')) || mediaArray[0];
@@ -94,7 +123,6 @@ class MediaDownloaderService {
});
}
async downloadFile(url) {
const response = await axios({
url: url,
@@ -104,7 +132,6 @@ class MediaDownloaderService {
return response;
}
}
module.exports = new MediaDownloaderService();