Download src/const.proxied.js from hankchin/bitsai: direct link, hf CLI and curl.
- Browser
- Download file 2.75 kB
-
https://huggingface.co/spaces/hankchin/bitsai/resolve/main/src/const.proxied.js
- Command line
-
hf download hf://spaces/hankchin/bitsai/src/const.proxied.js
-
curl -L -o const.proxied.js https://huggingface.co/spaces/hankchin/bitsai/resolve/main/src/const.proxied.js
2.75 kB
| /** | |
| * 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; | |
| } |