Spaces:
Running
Running
Z User commited on
Commit ·
e1c936b
1
Parent(s): 4c78e79
feat: add Vyla SDK (65 providers) via Node.js sidecar + /vyla endpoint
Browse files- Updated Dockerfile: install Node.js 22 alongside Python 3.11
- Added package.json with @vyla-entertainment/sdk dependency
- Added vyla-resolver.js: Node.js script that calls Vyla SDK getStream()
for 19 default providers (vidlink, vidy, vidfast, vidup, cinesrc, hexa,
chillflix, vidora, meowtv, vidspark, torrentio, braflix, rivestream,
vidbolt, moviebox, net79, watchout, vidzee, vidlux, allaboutmovies)
- Added /vyla/{tmdb_id} endpoint to main.py that spawns the Node.js
resolver as a subprocess and returns JSON with resolved streams
- rivestream provides 5 separate audio tracks (English/Spanish/Hindi/
Tamil/Telugu) for multi-audio playback
- castle + netmirror remain as the primary Python scrapers (unchanged)
Files changed (4)
- Dockerfile+11
- main.py+30
- package.jsonAdded+8
- vyla-resolver.jsAdded+70
12345678910FROM python:3.11-slimWORKDIR /appCOPY requirements.txt .RUN pip install --no-cache-dir -r requirements.txtCOPY . .EXPOSE 7860123456789101112131415161718192021FROM python:3.11-slim# Install Node.js 22 for Vyla SDK (server-side scraping)RUN apt-get update && apt-get install -y curl && \curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \apt-get install -y nodejs && \apt-get clean && rm -rf /var/lib/apt/lists/*WORKDIR /app# Python dependenciesCOPY requirements.txt .RUN pip install --no-cache-dir -r requirements.txt# Node.js dependencies (Vyla SDK)COPY package.json .RUN npm install --omit=devCOPY . .EXPOSE 7860
2627 unmodified lines2628262926302627 unmodified linesif __name__ == "__main__":import uvicornuvicorn.run(app, host="0.0.0.0", port=7860)2627 unmodified lines2628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602627 unmodified linesif __name__ == "__main__":import uvicornuvicorn.run(app, host="0.0.0.0", port=7860)# ─── Vyla SDK integration (Node.js sidecar) ─────────────────────────────────# Calls the Vyla SDK (65 providers) via a Node.js subprocess. The Python API# can't import the Node.js SDK directly, so we spawn a subprocess that runs# vyla-resolver.js and parses its JSON output.import subprocess, json as _json@app.get('/vyla/{tmdb_id}')async def vyla_resolve(tmdb_id: int, type: str = 'movie', season: int = 0, episode: int = 0, sources: str = ''):'''Resolve streams via Vyla SDK (65 providers). Returns JSON with candidates per source.'''try:args = _json.dumps({'tmdbId': tmdb_id,'type': type,'season': season if type == 'tv' else None,'episode': episode if type == 'tv' else None,'sources': sources,})proc = subprocess.run(['node', 'vyla-resolver.js'],input=args, capture_output=True, text=True, timeout=60)if proc.returncode != 0:return {'success': False, 'error': proc.stderr[:500]}return _json.loads(proc.stdout)except subprocess.TimeoutExpired:return {'success': False, 'error': 'Vyla resolver timed out (60s)'}except Exception as e:return {'success': False, 'error': str(e)[:200]}
12345678{ "name": "streamforge-vyla", "version": "1.0.0", "type": "module", "dependencies": { "@vyla-entertainment/sdk": "^1.29.0" }}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970// Vyla SDK resolver — called by StreamForge's Python API via subprocess.// Takes JSON args via stdin, outputs resolved sources as JSON to stdout.import VylaSDK from "@vyla-entertainment/sdk";
const sdk = new VylaSDK({ tmdbApiKey: "7967738a03ec215c7d6d6d675faba9c973"});
// Read args from stdinlet input = "";for await (const chunk of process.stdin) input += chunk;const { tmdbId, type, season, episode, sources: sourceFilter } = JSON.parse(input);
// Default: probe the fastest + most-track-rich providersconst DEFAULT_SOURCES = [ "vidlink", // 4K MP4, 4 qualities "vidy", // vidy.st (our existing default player) "vidfast", // 4K fMP4 HLS "vidup", // HLS "cinesrc", // HLS (CineSrc) "hexa", // HLS "chillflix", // up to 4K HEVC DV "vidora", // 34+ candidates "meowtv", // HLS "vidspark", // HLS 804p "torrentio", // torrent-backed, 4K "braflix", // MP4 via proxy "rivestream", // MULTI-AUDIO (5 tracks: English/Spanish/Hindi/Tamil/Telugu) "vidbolt", "moviebox", "net79", "watchout", "vidzee", // has Hindi services "vidlux", "allaboutmovies",];
const keys = sourceFilter ? sourceFilter.split(",") : DEFAULT_SOURCES;
const results = await Promise.allSettled( keys.map(async (key) => { const start = Date.now(); try { const result = await sdk.getStream(key, String(tmdbId), season, episode); const ms = Date.now() - start; if (!result || !result.url) return { key, ok: false, ms, error: "no stream" }; const candidates = result.allUrls || [{ url: result.url, quality: result.quality, type: result.type }]; return { key, ok: true, ms, candidates: candidates.map(c => ({ url: c.url, quality: c.quality || "Auto", type: c.url.includes(".m3u8") || c.type === "hls" ? "hls" : "mp4", headers: result.headers || {}, })), }; } catch (e) { return { key, ok: false, ms: Date.now() - start, error: e.message?.slice(0, 100) || String(e) }; } }));
const output = results.map((r, i) => ({ source: keys[i], ...r.value,}));
console.log(JSON.stringify({ success: true, tmdbId, type, season, episode, sources: output }));Dockerfile+11
main.py+30
package.jsonAdded+8
vyla-resolver.jsAdded+70