mirror of
https://github.com/Inside4ndroid/TMDB-Embed-API.git
synced 2026-10-22 09:35:11 +00:00
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:
+37
-14
@@ -5,6 +5,19 @@ const VIDLINK_HEADERS = {
|
||||
'Referer': 'https://vidlink.pro'
|
||||
};
|
||||
|
||||
function qualityToNumber(quality) {
|
||||
if (quality === '4k') return 2160;
|
||||
if (quality === 'Auto' || quality === 'unknown') return 0;
|
||||
const parsed = parseInt(quality, 10);
|
||||
return isNaN(parsed) ? 0 : parsed;
|
||||
}
|
||||
|
||||
function qualityLabel(quality) {
|
||||
if (quality === '4k') return '4K';
|
||||
if (quality === 'Auto' || quality === 'unknown') return 'Auto';
|
||||
return `${quality}p`;
|
||||
}
|
||||
|
||||
async function getVidlinkStreams(tmdbId, mediaType = 'movie', seasonNum = null, episodeNum = null) {
|
||||
console.log(`[Vidlink] Fetching streams for TMDB ID: ${tmdbId}, Type: ${mediaType}`);
|
||||
|
||||
@@ -20,32 +33,42 @@ async function getVidlinkStreams(tmdbId, mediaType = 'movie', seasonNum = null,
|
||||
return [];
|
||||
}
|
||||
|
||||
// Step 2: Fetch stream playlist from Vidlink API
|
||||
// Step 2: Fetch file-quality streams from Vidlink API
|
||||
const apiUrl = mediaType === 'tv'
|
||||
? `https://vidlink.pro/api/b/tv/${encodedTmdb}/${seasonNum}/${episodeNum}?multiLang=0`
|
||||
: `https://vidlink.pro/api/b/movie/${encodedTmdb}?multiLang=0`;
|
||||
|
||||
const apiRes = await axios.get(apiUrl, { headers: VIDLINK_HEADERS, timeout: 8000 });
|
||||
|
||||
const playlist = apiRes.data && apiRes.data.stream && apiRes.data.stream.playlist;
|
||||
if (!playlist) {
|
||||
console.log('[Vidlink] No playlist URL in response.');
|
||||
const streamData = apiRes.data && apiRes.data.stream;
|
||||
if (!streamData || !streamData.qualities) {
|
||||
console.log('[Vidlink] No quality streams in response.');
|
||||
return [];
|
||||
}
|
||||
|
||||
console.log(`[Vidlink] Got stream.`);
|
||||
return [{
|
||||
name: 'Vidlink',
|
||||
title: 'Vidlink',
|
||||
url: playlist,
|
||||
quality: 'Auto',
|
||||
provider: 'Vidlink',
|
||||
headers: { 'Referer': 'https://vidlink.pro' }
|
||||
}];
|
||||
const streams = Object.entries(streamData.qualities)
|
||||
.filter(([, entry]) => entry && entry.url)
|
||||
.sort((a, b) => qualityToNumber(b[0]) - qualityToNumber(a[0]))
|
||||
.map(([qualityKey, entry]) => ({
|
||||
name: 'Vidlink',
|
||||
title: `Vidlink - ${qualityLabel(qualityKey)}`,
|
||||
url: entry.url,
|
||||
quality: qualityKey,
|
||||
provider: 'Vidlink',
|
||||
headers: { 'Referer': 'https://vidlink.pro' }
|
||||
}));
|
||||
|
||||
if (streams.length === 0) {
|
||||
console.log('[Vidlink] No usable stream URLs in response.');
|
||||
return [];
|
||||
}
|
||||
|
||||
console.log(`[Vidlink] Got ${streams.length} stream(s).`);
|
||||
return streams;
|
||||
} catch (err) {
|
||||
console.error(`[Vidlink] Error: ${err.message}`);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { getVidlinkStreams };
|
||||
module.exports = { getVidlinkStreams };
|
||||
Reference in New Issue
Block a user