/** * STREAM_SOURCES with automatic proxy wrapping via proxyIfLocalAvailable * Applies wrapping dynamically without requiring caller to manually wrap each URL. */ // Error constants export const ERROR = { NOT_PREMIUM: 'NOT_PREMIUM', TORRENT_NOT_CACHED: 'TORRENT_NOT_CACHED', INVALID_MAGNET: 'INVALID_MAGNET', API_ERROR: 'API_ERROR', RATE_LIMITED: 'RATE_LIMITED', ACTIVE_LIMIT: 'ACTIVE_LIMIT', DOWNLOAD_LIMIT: 'DOWNLOAD_LIMIT' }; async function proxyIfLocalAvailable(url) { const proxyBase = 'http://127.0.0.1:11470/proxy/'; try { if (!/^https?:/.test(url)) return url; const testProxy = await fetch(proxyBase + encodeURIComponent('https://stremio.com'), { method: 'HEAD', mode: 'no-cors' }); if (testProxy.ok || testProxy.status === 200 || testProxy.type === 'opaque') { const proxiedUrl = proxyBase + encodeURIComponent(url); console.debug('[proxyIfLocalAvailable] Proxying through localhost:', proxiedUrl); return proxiedUrl; } } catch (err) { console.debug('[proxyIfLocalAvailable] Proxy fallback. Error:', err.message); } return url; } const RAW_STREAM_SOURCES = { cf_tpb: { url: 'https://hankchin-7331-gem.hf.space', name: 'π•Ώπ–π–Š π•»π–Žπ–—π–†π–™π–Š π•­π–†π–ž' }, hankchin_bitsai: { url: 'https://hankchin-connection2.hf.space', name: 'πŸ†ƒπŸ…ΎπŸ†πŸ†πŸ…΄πŸ…½πŸ†ƒπŸ†‰βž’' }, cf_rutrack: { url: 'https://hankchin-connection2.hf.space', name: 'β˜­πŸ‡·πŸ‡Ίπ‘‘α΅£β‚π‘β²•β‚‘α΅£' }, mikmc5_hjacy: { url: 'https://hankchin-hqknaben.hf.space', name: '𝕁𝕒𝕔𝕣𝕖𝕕 (^β€Ώβ€’)' }, hankchin_animai: { url: 'https://hankchin-animai.hf.space', name: '𝕄𝕀𝕃𝕂𝕀𝔼' }, mikmc5_tscv: { url: 'https://hankchin-ybt.hf.space', name: '𝐓𝐂𝐒𝐕' }, mikmc5_vrasbs: { url: 'https://hankchin-vrasbs-ai.hf.space', name: '𝐓𝐂𝐒𝐕' }, hankchin_animai2: { url: 'https://hankchin-animai2.hf.space', name: 'TOα–‡α’ͺOα‘•K' } }; // Export the static STREAM_SOURCES for immediate use (for compatibility) export const STREAM_SOURCES = RAW_STREAM_SOURCES; /** * Returns STREAM_SOURCES with proxy-wrapped URLs applied at runtime. * Call this before using the sources. */ export async function getProxiedStreamSources() { const wrapped = {}; for (const [key, source] of Object.entries(RAW_STREAM_SOURCES)) { wrapped[key] = { ...source, url: await proxyIfLocalAvailable(source.url) }; } return wrapped; }