diff --git a/addon/lib/getManifest.js b/addon/lib/getManifest.js index 0bd6bf6..3a5d52e 100644 --- a/addon/lib/getManifest.js +++ b/addon/lib/getManifest.js @@ -114,27 +114,49 @@ async function getManifest(config) { const filterLanguages = setOrderLanguage(language, languagesArray); const options = { years, genres_movie, genres_series, filterLanguages }; - 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, userCatalog.showInHome, options); - - return createCatalog( - userCatalog.id, - userCatalog.type, - catalogDef, - catalogOptions, - tmdbPrefix, - translatedCatalogs, - userCatalog.showInHome - ); - }); + // Criar catálogos base + let 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, userCatalog.showInHome, options); + + return createCatalog( + userCatalog.id, + userCatalog.type, + catalogDef, + catalogOptions, + tmdbPrefix, + translatedCatalogs, + userCatalog.showInHome + ); + }); + + // Adicionar catálogo de busca se searchEnabled não for false + if (config.searchEnabled !== "false") { + const searchCatalogMovie = { + id: "tmdb.search", + type: "movie", + name: `${tmdbPrefix ? "TMDB - " : ""}${translatedCatalogs.search}`, + pageSize: 20, + extra: [{ name: "search" }] + }; + + const searchCatalogSeries = { + id: "tmdb.search", + type: "series", + name: `${tmdbPrefix ? "TMDB - " : ""}${translatedCatalogs.search}`, + pageSize: 20, + extra: [{ name: "search" }] + }; + + catalogs = [...catalogs, searchCatalogMovie, searchCatalogSeries]; + } const descriptionSuffix = language && language !== DEFAULT_LANGUAGE ? ` with ${language} language.` : "."; diff --git a/addon/static/catalog-types.json b/addon/static/catalog-types.json index 88115ed..d92c2a7 100644 --- a/addon/static/catalog-types.json +++ b/addon/static/catalog-types.json @@ -2,7 +2,7 @@ "default": { "top": { "nameKey": "popular", - "extraSupported": ["genre", "skip", "search"] + "extraSupported": ["genre", "skip"] }, "year": { "nameKey": "year", diff --git a/addon/static/translations.json b/addon/static/translations.json index 7aadb98..3674865 100644 --- a/addon/static/translations.json +++ b/addon/static/translations.json @@ -6,6 +6,7 @@ "trending": "Trending", "favorites": "Favorites", "watchlist": "Watchlist", + "search": "Search", "nfx": "Netflix", "nfk": "Netflix Kids", "hbm": "HBO Max", diff --git a/configure/src/components/AgeRatingSelect.tsx b/configure/src/components/AgeRatingSelect.tsx index a148ac3..0e0d3fa 100644 --- a/configure/src/components/AgeRatingSelect.tsx +++ b/configure/src/components/AgeRatingSelect.tsx @@ -22,7 +22,7 @@ export function AgeRatingSelect() { return (
- +
Not available for trending catalogs diff --git a/configure/src/components/SearchToggle.tsx b/configure/src/components/SearchToggle.tsx new file mode 100644 index 0000000..55305fa --- /dev/null +++ b/configure/src/components/SearchToggle.tsx @@ -0,0 +1,19 @@ +import { Switch } from "@/components/ui/switch"; +import { useConfig } from "@/contexts/ConfigContext"; +import { Card } from "@/components/ui/card"; + +export function SearchToggle() { + const { searchEnabled, setSearchEnabled } = useConfig(); + + return ( + +
+ +

+ Allow searching for movies and TV shows +

+
+ +
+ ); +} diff --git a/configure/src/contexts/ConfigContext.tsx b/configure/src/contexts/ConfigContext.tsx index 4999af8..c50c904 100644 --- a/configure/src/contexts/ConfigContext.tsx +++ b/configure/src/contexts/ConfigContext.tsx @@ -26,6 +26,7 @@ export function ConfigProvider({ children }: { children: React.ReactNode }) { const [streaming, setStreaming] = useState([]); const [catalogs, setCatalogs] = useState([]); const [ageRating, setAgeRating] = useState(undefined); + const [searchEnabled, setSearchEnabled] = useState(true); const loadConfigFromUrl = () => { try { @@ -60,6 +61,8 @@ export function ConfigProvider({ children }: { children: React.ReactNode }) { setStreaming(Array.from(selectedStreamingServices) as string[]); } + if (config.searchEnabled) setSearchEnabled(config.searchEnabled === "true"); + window.history.replaceState({}, '', '/configure'); } catch (error) { console.error('Error loading config from URL:', error); @@ -82,6 +85,7 @@ export function ConfigProvider({ children }: { children: React.ReactNode }) { streaming, catalogs, ageRating, + searchEnabled, setRpdbkey, setMdblistkey, setIncludeAdult, @@ -92,6 +96,7 @@ export function ConfigProvider({ children }: { children: React.ReactNode }) { setStreaming, setCatalogs, setAgeRating, + setSearchEnabled, loadConfigFromUrl }; diff --git a/configure/src/contexts/config.ts b/configure/src/contexts/config.ts index 01fc094..4d72142 100644 --- a/configure/src/contexts/config.ts +++ b/configure/src/contexts/config.ts @@ -7,7 +7,7 @@ export type CatalogConfig = { showInHome: boolean; }; -export interface ConfigContextType { +export type ConfigContextType = { rpdbkey: string; mdblistkey: string; includeAdult: boolean; @@ -17,17 +17,20 @@ export interface ConfigContextType { sessionId: string; streaming: string[]; catalogs: CatalogConfig[]; - ageRating: string; - setRpdbkey: (value: string) => void; - setMdblistkey: (value: string) => void; - setIncludeAdult: (value: boolean) => void; - setProvideImdbId: (value: boolean) => void; - setTmdbPrefix: (value: boolean) => void; - setLanguage: (value: string) => void; - setSessionId: (value: string) => void; - setStreaming: (value: string[]) => void; - setCatalogs: (value: CatalogConfig[] | ((prev: CatalogConfig[]) => CatalogConfig[])) => void; - setAgeRating: (value: string) => void; -} + ageRating: string | undefined; + searchEnabled: boolean; + setRpdbkey: (rpdbkey: string) => void; + setMdblistkey: (mdblistkey: string) => void; + setIncludeAdult: (includeAdult: boolean) => void; + setProvideImdbId: (provideImdbId: boolean) => void; + setTmdbPrefix: (tmdbPrefix: boolean) => void; + setLanguage: (language: string) => void; + setSessionId: (sessionId: string) => void; + setStreaming: (streaming: string[]) => void; + setCatalogs: (catalogs: CatalogConfig[]) => void; + setAgeRating: (ageRating: string | undefined) => void; + setSearchEnabled: (enabled: boolean) => void; + loadConfigFromUrl: () => void; +}; export const ConfigContext = createContext(undefined); \ No newline at end of file diff --git a/configure/src/lib/config.ts b/configure/src/lib/config.ts index 92e6463..68e346e 100644 --- a/configure/src/lib/config.ts +++ b/configure/src/lib/config.ts @@ -7,6 +7,7 @@ interface AddonConfig { language?: string; sessionId?: string; ageRating?: string; + searchEnabled?: boolean; catalogs?: Array<{ id: string; type: string; @@ -28,7 +29,8 @@ export function generateAddonUrl(config: AddonConfig): string { })) || undefined, includeAdult: config.includeAdult === true ? "true" : undefined, provideImdbId: config.provideImdbId === true ? "true" : undefined, - tmdbPrefix: config.tmdbPrefix === true ? "true" : undefined + tmdbPrefix: config.tmdbPrefix === true ? "true" : undefined, + searchEnabled: config.searchEnabled === false ? "false" : undefined, }; // Remover propriedades undefined/null diff --git a/configure/src/pages/Others.tsx b/configure/src/pages/Others.tsx index c24426c..5478eab 100644 --- a/configure/src/pages/Others.tsx +++ b/configure/src/pages/Others.tsx @@ -2,6 +2,7 @@ import { Card } from "@/components/ui/card"; import { Switch } from "@/components/ui/switch"; import { useConfig } from "@/contexts/ConfigContext"; import { AgeRatingSelect } from "@/components/AgeRatingSelect"; +import { SearchToggle } from "@/components/SearchToggle"; const Others = () => { const { includeAdult, setIncludeAdult } = useConfig(); @@ -17,20 +18,15 @@ const Others = () => {

- - - +
-

Enable adult content

-

+

Enable adult content

+

Include adult content in search results

- +
@@ -38,7 +34,8 @@ const Others = () => { Provide IMDB metadata

- Include IMDB IDs in metadata for better integration with other addons. + Include IMDB IDs in metadata for better integration with other + addons.

{
-

- Use TMDB prefix -

+

Use TMDB prefix

Add "TMDB -" prefix to all catalog names for better organization.

@@ -60,6 +55,9 @@ const Others = () => { onCheckedChange={() => setTmdbPrefix(!tmdbPrefix)} /> + + +
);