Add new providers for streaming services and utility functions

- Implement StreamFlix provider for fetching movie and episode streams.
- Add VaPlayer provider to retrieve streaming URLs for movies and TV shows.
- Introduce ZXCStreams provider for accessing various streaming links.
- Create utility functions for fetching episode counts from Cinemeta.
- Develop a title matching system for improved search results.
- Implement TMDB title to IMDB ID resolution for better integration with TMDB API.
This commit is contained in:
Inside4ndroid
2026-08-19 23:35:13 +01:00
parent 01f06f807e
commit 2c9a2cabbf
30 changed files with 2791 additions and 516 deletions
+66
View File
@@ -0,0 +1,66 @@
// Episode count per season from Cinemeta.
// Ported from Infinite-streams (src/lib/cinemeta.ts getEpisodesPerSeason).
const CINEMETA_BASE = 'https://v3-cinemeta.strem.io';
const CACHE_TTL_MS = 6 * 60 * 60 * 1000;
const FETCH_TIMEOUT_MS = 12000;
const episodeCountCache = new Map();
async function getEpisodesPerSeason(imdbId) {
const cacheKey = `eps:${imdbId}`;
const cached = episodeCountCache.get(cacheKey);
if (cached && Date.now() - cached.ts < CACHE_TTL_MS) {
return cached.data;
}
try {
const url = `${CINEMETA_BASE}/meta/series/${imdbId}.json`;
const res = await fetch(url, {
headers: { 'User-Agent': 'Stremio Addon' },
signal: AbortSignal.timeout(FETCH_TIMEOUT_MS),
});
if (!res.ok) {
episodeCountCache.set(cacheKey, { data: [], ts: Date.now() });
return [];
}
const json = await res.json();
const videos = (json.meta && json.meta.videos) || [];
if (videos.length === 0) {
episodeCountCache.set(cacheKey, { data: [], ts: Date.now() });
return [];
}
const seasonMaxEp = new Map();
for (const v of videos) {
if (!v.season || v.season <= 0) continue;
const ep = v.number || v.episode || 0;
if (ep > 0) {
const prev = seasonMaxEp.get(v.season) || 0;
seasonMaxEp.set(v.season, Math.max(prev, ep));
}
}
if (seasonMaxEp.size === 0) {
episodeCountCache.set(cacheKey, { data: [], ts: Date.now() });
return [];
}
const maxSeason = Math.max(...seasonMaxEp.keys());
const result = [];
for (let s = 1; s <= maxSeason; s++) {
result.push(seasonMaxEp.get(s) || 0);
}
episodeCountCache.set(cacheKey, { data: result, ts: Date.now() });
return result;
} catch (err) {
console.error(`[Cinemeta] getEpisodesPerSeason error: ${err.message}`);
episodeCountCache.set(cacheKey, { data: [], ts: Date.now() });
return [];
}
}
module.exports = { getEpisodesPerSeason };