// MoviesClub Provider // Extracts streams from moviesapi.club const axios = require('axios'); const JsUnpacker = require('../utils/jsunpack'); async function getMoviesClubStreams(tmdbId, mediaType, season, episode) { console.log(`[moviesclub] Fetching streams for ${mediaType} tmdbId=${tmdbId} season=${season} episode=${episode}`); const streams = []; try { // Build the URL based on media type let url; if (mediaType === 'movie') { url = `https://moviesapi.club/movie/${tmdbId}`; } else if (mediaType === 'tv' && season && episode) { url = `https://moviesapi.club/tv/${tmdbId}-${season}-${episode}`; } else { console.log('[moviesclub] Invalid parameters for TV show'); return []; } console.log(`[moviesclub] Fetching from: ${url}`); // Fetch the main page const response = await axios.get(url, { timeout: 10000, headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Accept-Language': 'en-US,en;q=0.5', 'Accept-Encoding': 'gzip, deflate', 'Connection': 'keep-alive', 'Upgrade-Insecure-Requests': '1' } }); const html = response.data; console.log(`[moviesclub] Fetched ${html.length} characters`); // Extract data-url from srvswitch-menu const dataUrlMatch = html.match(/data-url="([^"]+)"/); if (!dataUrlMatch) { console.log('[moviesclub] No data-url found in HTML'); return []; } const embedUrl = dataUrlMatch[1]; console.log(`[moviesclub] Found embed URL: ${embedUrl}`); // Check if this is a cdn.moviesapi.club embed URL with multiple servers if (embedUrl.includes('cdn.moviesapi.club')) { console.log('[moviesclub] Detected cdn.moviesapi.club embed URL, handling multiple servers'); return await handleMultipleServers(embedUrl, mediaType, season, episode, tmdbId); } // Handle regular embed URLs (existing logic) return await handleSingleServer(embedUrl, mediaType, season, episode, tmdbId); } catch (error) { console.error(`[moviesclub] Error:`, error.message); return []; } } // Handle cdn.moviesapi.club URLs with multiple servers async function handleMultipleServers(embedUrl, mediaType, season, episode, tmdbId) { console.log(`[moviesclub] Handling multiple servers from: ${embedUrl}`); const streams = []; try { // Fetch the embed page const embedResponse = await axios.get(embedUrl, { timeout: 10000, headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Accept-Language': 'en-US,en;q=0.5', 'Accept-Encoding': 'gzip, deflate', 'Connection': 'keep-alive' } }); const embedHtml = embedResponse.data; console.log(`[moviesclub] Fetched embed page: ${embedHtml.length} characters`); // Extract server options from the HTML const serverMatches = embedHtml.match(/