minor fixes/changes

This commit is contained in:
X4Lo committed 2024-06-23 17:01:31 +01:00
1 parent 252f15ffd9
commit 336519be70
8 files changed
+41 -10

No files matched your search

+3 -1
View File
@@ -12,6 +12,8 @@ const { Sequelize } = require('sequelize');
const router = express.Router();
const multer = require('multer');
const { v4: uuidv4 } = require('uuid');
const path = require('path');
const { getMediaFolder } = require('../services/mediaService');
// ! /user-collections
// * POST - CREATE UserCollection
@@ -82,7 +84,7 @@ router.get('/:id', async (req, res) => {
const storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, 'uploads/collections/posters/')
cb(null, path.join(getMediaFolder(), 'images', 'collections', 'posters'))
},
filename: function (req, file, cb) {
const uniqueFilename = uuidv4();
+3 -3
View File
@@ -512,9 +512,9 @@ async function refrechEntry(entryId) {
// ? if the count of a media type == 0, the add the type to mediaToGet
let mediaToGet = [];
availableMedia.forEach(({ type, count }) => {
if (count == 0) mediaToGet.push(type);
});
for (let key in availableMedia) {
if (availableMedia[key] == 0) mediaToGet.push(availableMedia[key]);
}
if (mediaToGet.length != 0) {
downloadedImages = await getEntryMedia(data.id, oldEntry.is_tvseries, mediaToGet);
+7
View File
@@ -97,6 +97,10 @@ function scheduleDownloads(media, mediaType, mediaDir, downloadTasks, downloaded
);
}
function getMediaFolder() {
return getSettings().userDataPath;
}
function createMediaFolders() {
const settings = getSettings();
const dataPath = settings.userDataPath;
@@ -104,10 +108,12 @@ function createMediaFolders() {
const posterDir = path.join(dataPath, 'images', 'entries', 'posters');
const backdropDir = path.join(dataPath, 'images', 'entries', 'backdrops');
const logoDir = path.join(dataPath, 'images', 'entries', 'logos');
const collectionsPostersDir = path.join(dataPath, 'images', 'collections', 'posters');
fs.mkdirSync(posterDir, { recursive: true });
fs.mkdirSync(backdropDir, { recursive: true });
fs.mkdirSync(logoDir, { recursive: true });
fs.mkdirSync(collectionsPostersDir, { recursive: true });
// console.log(`Created media folders.`);
}
@@ -115,4 +121,5 @@ function createMediaFolders() {
module.exports = {
getEntryMedia,
createMediaFolders,
getMediaFolder,
};