mirror of
https://github.com/Viren070/tmdb-addon.git
synced 2025-12-01 23:18:11 +01:00
Update to sort catalogs as in configuration
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"projectName": "tmdb-addon",
|
||||
"lastCommit": "c2b4805"
|
||||
"lastCommit": "0c74237"
|
||||
}
|
||||
+21
-39
@@ -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.` : ".";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user