B: add download of season media + maintenance

This commit is contained in:
X4Lo committed 2025-02-20 01:34:42 +01:00
1 parent d799ef2368
commit 534572775f
6 files changed
+76 -16

No files matched your search

+17 -13
View File
@@ -18,12 +18,12 @@ class MaintenanceService {
return MaintenanceService.instance;
}
/**
* Delete orphan media records from database,
* orphan media records are media records that exist in the database
* but do not have a file in the `folder data`
* @param {boolean} [dry=false] - if true only return the count of the files that are getting deleted, default=`false`
*/
/**
* Delete orphan media records from database,
* orphan media records are media records that exist in the database
* but do not have a file in the `folder data`
* @param {boolean} [dry=false] - if true only return the count of the files that are getting deleted, default=`false`
*/
async deleteOrphanMediaRecords(dry = false) {
const allMedia = await Media.findAll();
@@ -32,19 +32,21 @@ class MaintenanceService {
// Handling different media types
const mediaTypeFolder = {
'entryposter': path.join(dataPath, 'images', 'entries', 'posters'),
'entrylogo': path.join(dataPath, 'images', 'entries', 'logos'),
'entrybackdrop': path.join(dataPath, 'images', 'entries', 'backdrops'),
'entry;poster': path.join(dataPath, 'images', 'entries', 'posters'),
'entry;logo': path.join(dataPath, 'images', 'entries', 'logos'),
'entry;backdrop': path.join(dataPath, 'images', 'entries', 'backdrops'),
'collectionposter': path.join(dataPath, 'images', 'collections', 'posters'),
'collectionlogo': path.join(dataPath, 'images', 'collections', 'logos'),
'collectionbackdrop': path.join(dataPath, 'images', 'collections', 'backdrops')
'collection;poster': path.join(dataPath, 'images', 'collections', 'posters'),
'collection;backdrop': path.join(dataPath, 'images', 'collections', 'backdrops'),
'season;poster': path.join(dataPath, 'images', 'seasons', 'posters')
};
let missingFiles = [];
for (let i = 0; i < allMedia.length; i++) {
const folderType = `${allMedia[i].mediaable}${allMedia[i].type.replace("_preview", "")}`;
if (!mediaTypeFolder[folderType]) continue
const filePath = path.join(mediaTypeFolder[folderType], allMedia[i].path)
if (!fs.existsSync(filePath)) {
missingFiles.push(allMedia[i]);
@@ -103,7 +105,9 @@ class MaintenanceService {
'entry;backdrop': path.join(dataPath, 'images', 'entries', 'backdrops'),
'collection;poster': path.join(dataPath, 'images', 'collections', 'posters'),
'collection;backdrop': path.join(dataPath, 'images', 'collections', 'backdrops')
'collection;backdrop': path.join(dataPath, 'images', 'collections', 'backdrops'),
'season;poster': path.join(dataPath, 'images', 'seasons', 'posters')
};
// * counter