mirror of
https://github.com/Viren070/tmdb-addon.git
synced 2025-12-01 23:18:11 +01:00
fix: ensure default catalogs are loaded on direct installation
- Add getDefaultCatalogs function using catalog-types.json - Use default catalogs when no catalogs are configured - Add minimum vote count filter to improve content quality - Remove unused getTrending import This fixes the issue where installing the addon directly without configuration would result in no catalogs being available.
This commit is contained in:
@@ -3,7 +3,6 @@ const { MovieDb } = require("moviedb-promise");
|
||||
const moviedb = new MovieDb(process.env.TMDB_API);
|
||||
const { getGenreList } = require("./getGenreList");
|
||||
const { getLanguages } = require("./getLanguages");
|
||||
const { getTrending } = require("./getTrending");
|
||||
const { parseMedia } = require("../utils/parseProps");
|
||||
const CATALOG_TYPES = require("../static/catalog-types.json");
|
||||
|
||||
@@ -22,10 +21,10 @@ async function getCatalog(type, language, page, id, genre, config) {
|
||||
|
||||
async function buildParameters(type, language, page, id, genre, genreList, config) {
|
||||
const languages = await getLanguages();
|
||||
const parameters = { language, page };
|
||||
const parameters = { language, page, 'vote_count.gte': 10 };;
|
||||
|
||||
if (config.ageRating) {
|
||||
switch(config.ageRating) {
|
||||
switch (config.ageRating) {
|
||||
case "G":
|
||||
parameters.certification_country = "US";
|
||||
parameters.certification = type === "movie" ? "G" : "TV-G";
|
||||
@@ -58,7 +57,7 @@ async function buildParameters(type, language, page, id, genre, genreList, confi
|
||||
switch (id) {
|
||||
case "tmdb.top":
|
||||
parameters.with_genres = genre ? findGenreId(genre, genreList) : undefined;
|
||||
if (type === "tv") {
|
||||
if (type === "series") {
|
||||
parameters.watch_region = language.split("-")[1];
|
||||
parameters.with_watch_monetization_types = "flatrate|free|ads|rent|buy";
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ async function getManifest(config) {
|
||||
const tmdbPrefix = config.tmdbPrefix === "true";
|
||||
const provideImdbId = config.provideImdbId === "true";
|
||||
const sessionId = config.sessionId;
|
||||
const userCatalogs = config.catalogs || [];
|
||||
const userCatalogs = config.catalogs || getDefaultCatalogs();
|
||||
const translatedCatalogs = loadTranslations(language);
|
||||
|
||||
const years = generateArrayOfYears(20);
|
||||
@@ -179,4 +179,17 @@ async function getManifest(config) {
|
||||
};
|
||||
}
|
||||
|
||||
function getDefaultCatalogs() {
|
||||
const defaultTypes = ['movie', 'series'];
|
||||
const defaultCatalogs = Object.keys(CATALOG_TYPES.default);
|
||||
|
||||
return defaultCatalogs.flatMap(id =>
|
||||
defaultTypes.map(type => ({
|
||||
id: `tmdb.${id}`,
|
||||
type,
|
||||
showInHome: true
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = { getManifest, DEFAULT_LANGUAGE };
|
||||
Reference in New Issue
Block a user