diff --git a/vidfast/vidfast.js b/vidfast/vidfast.js index e1ca9d3..7690697 100644 --- a/vidfast/vidfast.js +++ b/vidfast/vidfast.js @@ -372,16 +372,32 @@ async function ilovefeet(imdbId, isSeries = false, season = null, episode = null const staticPathMatch = configText.match(/static_path\s*=\s*['"]([^'"]+)['"]/); const sourceCharsMatch = configText.match(/source_chars\s*=\s*['"]([^'"]+)['"]/); const targetCharsMatch = configText.match(/target_chars\s*=\s*['"]([^'"]+)['"]/); + + const apiServersMatch = configText.match(/api_servers\s*=\s*f?['"]([^'"]+)['"]/); + const apiStreamMatch = configText.match(/api_stream\s*=\s*f?['"]([^'"]+)['"]/); + + const baseUrlMatch = configText.match(/base_url\s*=\s*['"]([^'"]+)['"]/); + const userAgentMatch = configText.match(/user_agent\s*=\s*['"]([^'"]+)['"]/); + const csrfTokenMatch = configText.match(/["']X-Csrf-Token["']:\s*["']([^'"]+)['"]/); + const refererMatch = configText.match(/["']Referer["']:\s*["']([^'"]+)['"]/); if (!keyHexMatch || !ivHexMatch || !xorKeyMatch || !staticPathMatch || !sourceCharsMatch || !targetCharsMatch) { throw new Error('Failed to extract config values'); } + const convertPythonFString = (str) => { + if (!str) return null; + return str + .replace(/\{static_path\}/g, '{STATIC_PATH}') + .replace(/\{encoded_final\}/g, '{ENCODED_FINAL}') + .replace(/\{server\}/g, '{SERVER}'); + }; + const config = { pageMovie: "https://vidfast.pro/movie/{IMDB_ID}", pageSeries: "https://vidfast.pro/tv/{IMDB_ID}/{SEASON}/{EPISODE}", - apiServers: "https://vidfast.pro/{STATIC_PATH}/3xNAjSIxZx0b/{ENCODED_FINAL}", - apiStream: "https://vidfast.pro/{STATIC_PATH}/Ici0cUs4soE/{SERVER}", + apiServers: apiServersMatch ? convertPythonFString(apiServersMatch[1]) : "https://vidfast.pro/{STATIC_PATH}/wfPFjh__qQ/{ENCODED_FINAL}", + apiStream: apiStreamMatch ? convertPythonFString(apiStreamMatch[1]) : "https://vidfast.pro/{STATIC_PATH}/AddlBFe5/{SERVER}", aesKeyHex: keyHexMatch[1], aesIvHex: ivHexMatch[1], @@ -401,12 +417,24 @@ async function ilovefeet(imdbId, isSeries = false, season = null, episode = null baseUrl = config.pageMovie.replace('{IMDB_ID}', imdbId); } + let defaultDomain = "https://vidfast.pro/"; + if (baseUrlMatch && baseUrlMatch[1]) { + const urlParts = baseUrlMatch[1].match(/^(https?:\/\/[^\/]+)/); + if (urlParts && urlParts[1]) { + defaultDomain = urlParts[1] + '/'; + } + } + const headers = { "Accept": "*/*", - "User-Agent": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Mobile Safari/537.36", - "Referer": "https://vidfast.pro/", + "User-Agent": userAgentMatch ? userAgentMatch[1] : "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Mobile Safari/537.36", + "Referer": refererMatch ? refererMatch[1] : defaultDomain, "X-Requested-With": "XMLHttpRequest" }; + + if (csrfTokenMatch && csrfTokenMatch[1]) { + headers["X-Csrf-Token"] = csrfTokenMatch[1]; + } const pageResponse = await fetchv2(baseUrl, headers); const pageText = await pageResponse.text();