Update to sort catalogs as in configuration

This commit is contained in:
mrcanelas
2025-02-02 12:30:43 -03:00
parent 8ce9f5e436
commit 6c62321d89
2 changed files with 22 additions and 40 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
{
"projectName": "tmdb-addon",
"lastCommit": "c2b4805"
"lastCommit": "0c74237"
}
+21 -39
View File
@@ -87,22 +87,6 @@ function getOptionsForCatalog(catalogDef, type, { years, genres_movie, genres_se
}
}
function sortCatalogs(catalogs) {
return catalogs.sort((a, b) => {
const typeA = a.id.split('.')[1];
const typeB = b.id.split('.')[1];
const orderA = Object.keys(CATALOG_TYPES).findIndex(category => CATALOG_TYPES[category][typeA]);
const orderB = Object.keys(CATALOG_TYPES).findIndex(category => CATALOG_TYPES[category][typeB]);
if (orderA !== orderB) {
return orderA - orderB;
}
return a.type === "movie" && b.type === "series" ? -1 : 1;
});
}
async function getManifest(config) {
const language = config.language || DEFAULT_LANGUAGE;
const tmdbPrefix = config.tmdbPrefix === "true";
@@ -127,29 +111,27 @@ async function getManifest(config) {
const filterLanguages = setOrderLanguage(language, languagesArray);
const options = { years, genres_movie, genres_series, filterLanguages };
const catalogs = sortCatalogs(
userCatalogs
.filter(userCatalog => {
const catalogDef = getCatalogDefinition(userCatalog.id);
if (!catalogDef) return false;
if (catalogDef.requiresAuth && !sessionId) return false;
return true;
})
.map(userCatalog => {
const catalogDef = getCatalogDefinition(userCatalog.id);
const catalogOptions = getOptionsForCatalog(catalogDef, userCatalog.type, options);
return createCatalog(
userCatalog.id,
userCatalog.type,
catalogDef,
catalogOptions,
tmdbPrefix,
translatedCatalogs,
userCatalog.showInHome
);
})
);
const catalogs = userCatalogs
.filter(userCatalog => {
const catalogDef = getCatalogDefinition(userCatalog.id);
if (!catalogDef) return false;
if (catalogDef.requiresAuth && !sessionId) return false;
return true;
})
.map(userCatalog => {
const catalogDef = getCatalogDefinition(userCatalog.id);
const catalogOptions = getOptionsForCatalog(catalogDef, userCatalog.type, options);
return createCatalog(
userCatalog.id,
userCatalog.type,
catalogDef,
catalogOptions,
tmdbPrefix,
translatedCatalogs,
userCatalog.showInHome
);
});
const descriptionSuffix = language && language !== DEFAULT_LANGUAGE ? ` with ${language} language.` : ".";