mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-01-11 20:10:25 +00:00
CP
This commit is contained in:
parent
335012c792
commit
1343da0dde
4 changed files with 26 additions and 13 deletions
|
|
@ -213,6 +213,8 @@ export const useMetadata = ({ id, type, addonId }: UseMetadataProps): UseMetadat
|
|||
seasonNum,
|
||||
episodeNum,
|
||||
tmdbApiKey: effectiveApiKey,
|
||||
title: (metadata as any)?.name || undefined,
|
||||
year: metadata?.year || undefined,
|
||||
});
|
||||
|
||||
const processTime = Date.now() - sourceStartTime;
|
||||
|
|
|
|||
|
|
@ -414,8 +414,8 @@ const SettingsScreen: React.FC = () => {
|
|||
icon="extension"
|
||||
onPress={() => navigation.navigate('Plugins')}
|
||||
renderControl={ChevronRight}
|
||||
isLast={true}
|
||||
/>
|
||||
isLast={true}
|
||||
/>
|
||||
</SettingsCard>
|
||||
|
||||
{/* Playback & Experience */}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ interface GetStreamsOptions {
|
|||
seasonNum?: number;
|
||||
episodeNum?: number;
|
||||
tmdbApiKey: string;
|
||||
// Optional metadata to avoid extra API calls
|
||||
title?: string;
|
||||
year?: string | number;
|
||||
// Injected properties
|
||||
logger: typeof logger;
|
||||
cache: Cache;
|
||||
|
|
@ -191,7 +194,7 @@ class PluginManager {
|
|||
if (persist) {
|
||||
await this.persistPluginUrl(url);
|
||||
}
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
logger.error(`[PluginManager] Plugin from ${url} executed but failed to register.`);
|
||||
|
|
@ -220,7 +223,7 @@ class PluginManager {
|
|||
};
|
||||
|
||||
// Require and execute the built-in MoviesMod plugin module (IIFE)
|
||||
//require('./plugins/moviesmod.plugin.js');
|
||||
require('./plugins/moviesmod.plugin.js');
|
||||
|
||||
delete (global as any).registerPlugin;
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -578,8 +578,9 @@
|
|||
// --- Main Plugin Entrypoint ---
|
||||
|
||||
async function mainGetStreams(options) {
|
||||
const { tmdbId, mediaType, seasonNum, episodeNum, tmdbApiKey, ...injected } = options;
|
||||
injected.logger.log(`[MoviesMod] Fetching streams for TMDB ${mediaType}/${tmdbId}${seasonNum ? `, S${seasonNum}E${episodeNum}`: ''}`);
|
||||
// Accept optional title/year passed from the host so we can skip TMDB calls when metadata is already available.
|
||||
const { tmdbId, mediaType, seasonNum, episodeNum, tmdbApiKey, title: providedTitle, year: providedYear, ...injected } = options;
|
||||
injected.logger.log(`[MoviesMod] Fetching streams for TMDB ${mediaType}/${tmdbId}${seasonNum ? ", S"+seasonNum+"E"+episodeNum: ''}`);
|
||||
|
||||
try {
|
||||
const cacheKey = `moviesmod_v7_${tmdbId}_${mediaType}${seasonNum ? `_s${seasonNum}` : ''}`;
|
||||
|
|
@ -587,13 +588,20 @@
|
|||
|
||||
if (!resolvedQualities) {
|
||||
injected.logger.log(`[MoviesMod Cache] MISS for key: ${cacheKey}.`);
|
||||
const tmdbUrl = `https://api.themoviedb.org/3/${mediaType === 'tv' ? 'tv' : 'movie'}/${tmdbId}?api_key=${tmdbApiKey}&language=en-US`;
|
||||
const tmdbResponse = await injected.fetch(tmdbUrl);
|
||||
const tmdbDetails = await tmdbResponse.json();
|
||||
|
||||
const title = mediaType === 'tv' ? tmdbDetails.name : tmdbDetails.title;
|
||||
const year = mediaType === 'tv' ? tmdbDetails.first_air_date?.substring(0, 4) : tmdbDetails.release_date?.substring(0, 4);
|
||||
if (!title) throw new Error('Could not get title from TMDB');
|
||||
// Prefer provided metadata to avoid extra API calls.
|
||||
let title = providedTitle;
|
||||
let year = providedYear ? String(providedYear) : undefined;
|
||||
|
||||
if (!title) {
|
||||
// Fallback to TMDB API if title is not provided.
|
||||
const tmdbUrl = `https://api.themoviedb.org/3/${mediaType === 'tv' ? 'tv' : 'movie'}/${tmdbId}?api_key=${tmdbApiKey}&language=en-US`;
|
||||
const tmdbResponse = await injected.fetch(tmdbUrl);
|
||||
const tmdbDetails = await tmdbResponse.json();
|
||||
title = mediaType === 'tv' ? tmdbDetails.name : tmdbDetails.title;
|
||||
year = mediaType === 'tv' ? tmdbDetails.first_air_date?.substring(0, 4) : tmdbDetails.release_date?.substring(0, 4);
|
||||
}
|
||||
|
||||
if (!title) throw new Error('Could not get title from metadata or TMDB');
|
||||
|
||||
const searchResults = await searchMoviesMod(title, injected);
|
||||
if (!searchResults.length) throw new Error(`No search results for "${title}"`);
|
||||
|
|
|
|||
Loading…
Reference in a new issue