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