mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-01-11 20:10:25 +00:00
some changes
This commit is contained in:
parent
563208689b
commit
14163513e3
2 changed files with 70 additions and 3 deletions
|
|
@ -1203,8 +1203,29 @@ export const useMetadata = ({ id, type, addonId }: UseMetadataProps): UseMetadat
|
|||
if (__DEV__) console.log('🔍 [loadEpisodeStreams] Getting TMDB ID for:', id);
|
||||
let tmdbId;
|
||||
let stremioEpisodeId = episodeId; // Default to original episode ID
|
||||
let isCollection = false;
|
||||
|
||||
if (id.startsWith('tmdb:')) {
|
||||
// Dynamically detect if this is a collection by checking addon capabilities
|
||||
const { isCollection: detectedCollection, addon: collectionAddon } = stremioService.isCollectionContent(id);
|
||||
isCollection = detectedCollection;
|
||||
|
||||
if (isCollection && collectionAddon) {
|
||||
if (__DEV__) console.log(`🎬 [loadEpisodeStreams] Detected collection from addon: ${collectionAddon.name}, treating episodes as individual movies`);
|
||||
|
||||
// For collections, extract the individual movie ID from the episodeId
|
||||
// episodeId format for collections: "tt7888964" (IMDb ID of individual movie)
|
||||
if (episodeId.startsWith('tt')) {
|
||||
// This is an IMDb ID of an individual movie in the collection
|
||||
tmdbId = await withTimeout(tmdbService.findTMDBIdByIMDB(episodeId), API_TIMEOUT);
|
||||
stremioEpisodeId = episodeId; // Use the IMDb ID directly for Stremio addons
|
||||
if (__DEV__) console.log('✅ [loadEpisodeStreams] Collection movie - using IMDb ID:', episodeId, 'TMDB ID:', tmdbId);
|
||||
} else {
|
||||
// Fallback: try to parse as TMDB ID
|
||||
tmdbId = episodeId;
|
||||
stremioEpisodeId = episodeId;
|
||||
if (__DEV__) console.log('⚠️ [loadEpisodeStreams] Collection movie - using episodeId as-is:', episodeId);
|
||||
}
|
||||
} else if (id.startsWith('tmdb:')) {
|
||||
tmdbId = id.split(':')[1];
|
||||
if (__DEV__) console.log('✅ [loadEpisodeStreams] Using TMDB ID from ID:', tmdbId);
|
||||
|
||||
|
|
@ -1259,7 +1280,12 @@ export const useMetadata = ({ id, type, addonId }: UseMetadataProps): UseMetadat
|
|||
|
||||
// Start Stremio request using the converted episode ID format
|
||||
if (__DEV__) console.log('🎬 [loadEpisodeStreams] Using episode ID for Stremio addons:', stremioEpisodeId);
|
||||
processStremioSource('series', stremioEpisodeId, true);
|
||||
|
||||
// For collections, treat episodes as individual movies, not series
|
||||
const contentType = isCollection ? 'movie' : 'series';
|
||||
if (__DEV__) console.log(`🎬 [loadEpisodeStreams] Using content type: ${contentType} for ${isCollection ? 'collection' : 'series'}`);
|
||||
|
||||
processStremioSource(contentType, stremioEpisodeId, true);
|
||||
|
||||
// Monitor scraper completion status instead of using fixed timeout
|
||||
const checkEpisodeScrapersCompletion = () => {
|
||||
|
|
@ -1531,7 +1557,21 @@ export const useMetadata = ({ id, type, addonId }: UseMetadataProps): UseMetadat
|
|||
}, []);
|
||||
|
||||
const getScraperCacheStats = useCallback(async () => {
|
||||
return await localScraperService.getCacheStats();
|
||||
const localStats = await localScraperService.getCacheStats();
|
||||
return {
|
||||
local: localStats.local,
|
||||
global: {
|
||||
totalEntries: 0,
|
||||
totalSize: 0,
|
||||
oldestEntry: null,
|
||||
newestEntry: null,
|
||||
hitRate: 0
|
||||
},
|
||||
combined: {
|
||||
totalEntries: localStats.local.totalEntries,
|
||||
hitRate: 0
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -240,6 +240,33 @@ class StremioService {
|
|||
return Array.from(prefixes);
|
||||
}
|
||||
|
||||
// Check if a content ID belongs to a collection addon
|
||||
public isCollectionContent(id: string): { isCollection: boolean; addon?: Manifest } {
|
||||
const addons = this.getInstalledAddons();
|
||||
|
||||
for (const addon of addons) {
|
||||
// Check if this addon supports collections
|
||||
const supportsCollections = addon.types?.includes('collections') ||
|
||||
addon.catalogs?.some(catalog => catalog.type === 'collections');
|
||||
|
||||
if (!supportsCollections) continue;
|
||||
|
||||
// Check if our ID matches this addon's prefixes
|
||||
const addonPrefixes = addon.idPrefixes || [];
|
||||
const resourcePrefixes = addon.resources
|
||||
?.filter(resource => typeof resource === 'object' && resource !== null && 'name' in resource)
|
||||
?.filter(resource => (resource as any).name === 'meta' || (resource as any).name === 'catalog')
|
||||
?.flatMap(resource => (resource as any).idPrefixes || []) || [];
|
||||
|
||||
const allPrefixes = [...addonPrefixes, ...resourcePrefixes];
|
||||
if (allPrefixes.some(prefix => id.startsWith(prefix))) {
|
||||
return { isCollection: true, addon };
|
||||
}
|
||||
}
|
||||
|
||||
return { isCollection: false };
|
||||
}
|
||||
|
||||
static getInstance(): StremioService {
|
||||
if (!StremioService.instance) {
|
||||
StremioService.instance = new StremioService();
|
||||
|
|
|
|||
Loading…
Reference in a new issue