From 4e3c9c208fe77367a41e9cd4b9dc68255c844dcc Mon Sep 17 00:00:00 2001 From: tapframe Date: Sat, 11 Oct 2025 01:20:26 +0530 Subject: [PATCH] type:tv addon detection fix --- src/components/home/ContinueWatchingSection.tsx | 2 +- src/services/catalogService.ts | 4 ++-- src/services/stremioService.ts | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/components/home/ContinueWatchingSection.tsx b/src/components/home/ContinueWatchingSection.tsx index 7fa89f1..b1084d8 100644 --- a/src/components/home/ContinueWatchingSection.tsx +++ b/src/components/home/ContinueWatchingSection.tsx @@ -124,7 +124,7 @@ const ContinueWatchingSection = React.forwardRef((props, re } try { - const shouldFetchMeta = stremioService.isValidContentId(type, id); + const shouldFetchMeta = await stremioService.isValidContentId(type, id); const [metadata, basicContent] = await Promise.all([ shouldFetchMeta ? stremioService.getMetaDetails(type, id) : Promise.resolve(null), catalogService.getBasicContentDetails(type, id) diff --git a/src/services/catalogService.ts b/src/services/catalogService.ts index 8c7b25c..01b4cd6 100644 --- a/src/services/catalogService.ts +++ b/src/services/catalogService.ts @@ -516,7 +516,7 @@ class CatalogService { console.log(`🔍 [CatalogService] Attempt ${i + 1}/2 for getContentDetails:`, { type, id, preferredAddonId }); // Skip meta requests for non-content ids (e.g., provider slugs) - const isValidId = stremioService.isValidContentId(type, id); + const isValidId = await stremioService.isValidContentId(type, id); console.log(`🔍 [CatalogService] Content ID validation:`, { type, id, isValidId }); if (!isValidId) { @@ -635,7 +635,7 @@ class CatalogService { for (let i = 0; i < 3; i++) { try { // Skip meta requests for non-content ids (e.g., provider slugs) - if (!stremioService.isValidContentId(type, id)) { + if (!(await stremioService.isValidContentId(type, id))) { break; } meta = await stremioService.getMetaDetails(type, id, preferredAddonId); diff --git a/src/services/stremioService.ts b/src/services/stremioService.ts index 8428b2b..5e7c00d 100644 --- a/src/services/stremioService.ts +++ b/src/services/stremioService.ts @@ -189,8 +189,8 @@ class StremioService { } // Dynamic validator for content IDs based on installed addon capabilities - public isValidContentId(type: string, id: string | null | undefined): boolean { - const isValidType = type === 'movie' || type === 'series'; + public async isValidContentId(type: string, id: string | null | undefined): Promise { + const isValidType = type === 'movie' || type === 'series' || type === 'tv'; const lowerId = (id || '').toLowerCase(); const isNullishId = !id || lowerId === 'null' || lowerId === 'undefined'; const providerLikeIds = new Set(['moviebox', 'torbox']); @@ -198,6 +198,9 @@ class StremioService { if (!isValidType || isNullishId || isProviderSlug) return false; + // Ensure addons are initialized before checking prefixes + await this.ensureInitialized(); + // Get all supported ID prefixes from installed addons const supportedPrefixes = this.getAllSupportedIdPrefixes(type); @@ -237,9 +240,6 @@ class StremioService { } } - // No hardcoded prefixes - let addons declare their own support dynamically - // If no addons declare prefixes, we'll allow any non-empty string - return Array.from(prefixes); } @@ -766,7 +766,7 @@ class StremioService { console.log(`🔍 [StremioService] getMetaDetails called:`, { type, id, preferredAddonId }); try { // Validate content ID first - const isValidId = this.isValidContentId(type, id); + const isValidId = await this.isValidContentId(type, id); console.log(`🔍 [StremioService] Content ID validation:`, { type, id, isValidId }); if (!isValidId) {