Spaces:
Running
Running
Z User commited on
Commit ·
d722b8e
1
Parent(s): d4916a1
v6: Remove HDMovie2, update VidSrc (CF-blocked note)
Browse filesFiles changed (2)
1339 unmodified lines134013411342134313431344134513466 unmodified lines1353135413551356135713581359136013561357136313641358135913601361136213681363136413701365136613721367136813691375137613771378137013711372137313811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051374137513761377137813791380138113821383138413851386138713881389139014071408140913911392139313941411141214131414141514161395139613971398139914001418141914011402140314041421142214231424142514261405140614281429143014071408140914101411141214131432143314341435143614141415141614381439144014411417141814191420142114221423144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481142414251426142714831484148514861487148814891490149114281429143014311432143314931494143414351436143714381439144014411442144314441445144614471448144914501451145215011453145414551456150514571458145914601461146214635 unmodified lines14691470147114721473147414751476147721 unmodified lines149915001501154415021503150415051547150615071508150986 unmodified lines159615971598164015991600160116021339 unmodified lines
# ===== VidSrc Scraper (cloudnestra via vsrc.su) =====# ===== VidSrc Scraper (cloudnestra via vidsrc.me) =====
async def scrape_vidsrc(tmdb_id: int, media_type: str, season: int = None, episode: int = None): results = []6 unmodified lines errors.append("VidSrc: Could not get IMDB ID from TMDB") return results, errors
CLOUD_HEADERS = { "Referer": "https://cloudnestra.com/", "Origin": "https://cloudnestra.com", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36", } DECRYPT_API = "https://enc-dec.app/api/dec-cloudnestra"
async with httpx.AsyncClient(timeout=20, follow_redirects=True, headers=CLOUD_HEADERS) as client: # Step 1: Get embed page from vsrc.su async with httpx.AsyncClient(timeout=20, follow_redirects=True, headers=HEADERS) as client: # Step 1: Get embed page from vidsrc.me if media_type == "tv": s = season or 1 e = episode or 1 embed_url = f"https://vsrc.su/embed/tv?imdb={imdb_id}&season={s}&episode={e}" embed_url = f"https://vidsrc.me/embed/tv/{imdb_id}/{s}/{e}/" else: embed_url = f"https://vsrc.su/embed/{imdb_id}" embed_url = f"https://vidsrc.me/embed/movie/{imdb_id}/"
embed_resp = await client.get(embed_url, headers={"User-Agent": CLOUD_HEADERS["User-Agent"]}) embed_resp = await client.get(embed_url) embed_html = embed_resp.text
# Extract iframe src iframe_m = re.search(r'<iframe[^>]+src=["\']([^"\']+)["\']', embed_html) if not iframe_m: errors.append("VidSrc: No iframe found in embed page") if "Cloudflare" in embed_html or embed_resp.status_code == 403: errors.append("VidSrc: Cloudflare blocked (datacenter IP)") return results, errors
iframe_src = iframe_m.group(1) if iframe_src.startswith("//"): iframe_src = "https:" + iframe_src elif iframe_src.startswith("/"): iframe_src = "https://vsrc.su" + iframe_src
# Step 2: Get iframe content iframe_resp = await client.get(iframe_src, headers={ "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:145.0) Gecko/20100101 Firefox/145.0", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language": "en-US,en;q=0.5", "Referer": "https://vsrc.su/", "Upgrade-Insecure-Requests": "1", }) iframe_html = iframe_resp.text
# Find prorcp source path prorcp_m = re.search(r'src:\\s*["\']([^"\']+)["\']', iframe_html) if not prorcp_m: errors.append("VidSrc: No prorcp source found in iframe") return results, errors
prorcp_src = prorcp_m.group(1) if prorcp_src.startswith("/"): prorcp_src = "https://cloudnestra.com" + prorcp_src # Extract cloudnestra iframe src iframe_m = re.search(r'<iframe[^>]+src="//cloudnestra\.com/rcp/([^"]+)"', embed_html) if not iframe_m: # Try alternative: vsembed.ru from vidsrc.to iframe_m2 = re.search(r'<iframe[^>]+src="(https://vsembed\.ru/[^"]+)"', embed_html) if iframe_m2: vsembed_url = iframe_m2.group(1) vsembed_resp = await client.get(vsembed_url, headers={"Referer": "https://vidsrc.to/"}) if "Cloudflare" in vsembed_resp.text or vsembed_resp.status_code == 403: errors.append("VidSrc: Cloudflare blocked on vsembed.ru") return results, errors # Parse vsembed page for streams (same flow as below) embed_html = vsembed_resp.text else: errors.append("VidSrc: No iframe found in embed page") return results, errors
# Step 3: Get cloudnestra page cloud_resp = await client.get(prorcp_src, headers={"Referer": "https://cloudnestra.com/"}) cloud_html = cloud_resp.text if iframe_m: encoded_path = iframe_m.group(1) cloudnestra_url = f"https://cloudnestra.com/rcp/{encoded_path}"
# Find hidden div with id and text hidden_pattern = r"""<div id="([^"]+)"[^>]*style=["\x27]display\s*:\s*none;?["\x27][^>]*>([a-zA-Z0-9:/.,{}_=+ -]+)</div>""" hidden_m = re.search(hidden_pattern, cloud_html) if not hidden_m: errors.append("VidSrc: No hidden div found in cloudnestra page") return results, errors # Step 2: Get cloudnestra page cloud_resp = await client.get(cloudnestra_url, headers={ "Referer": "https://vidsrc.me/", "Origin": "https://vidsrc.me", })
div_id = hidden_m.group(1) div_text = hidden_m.group(2) if cloud_resp.status_code == 403 or "Cloudflare" in cloud_resp.text: errors.append("VidSrc: Cloudflare blocked on cloudnestra.com") return results, errors
# Step 4: Decrypt via enc-dec.app dec_resp = await client.post( DECRYPT_API, json={"text": div_text, "div_id": div_id}, headers={"Content-Type": "application/json"}, ) cloud_html = cloud_resp.text
if dec_resp.status_code != 200: errors.append(f"VidSrc: Decrypt failed HTTP {dec_resp.status_code}") return results, errors # Find hidden div with id and text for decryption hidden_pattern = r"""<div id="([^"]+)"[^>]*style=["\x27]display\s*:\s*none;?["\x27][^>]*>([a-zA-Z0-9:/.,{}_=+ -]+)</div>""" hidden_m = re.search(hidden_pattern, cloud_html) if not hidden_m: errors.append("VidSrc: No hidden div found in cloudnestra page") return results, errors
dec_data = dec_resp.json() stream_urls = dec_data.get("result", []) if not isinstance(stream_urls, list) or not stream_urls: errors.append("VidSrc: No stream URLs after decryption") return results, errors div_id = hidden_m.group(1) div_text = hidden_m.group(2)
# Step 5: Check each stream URL quality for idx, stream_url in enumerate(stream_urls): if not stream_url: continue # Step 3: Decrypt via enc-dec.app dec_resp = await client.post( DECRYPT_API, json={"text": div_text, "div_id": div_id}, headers={"Content-Type": "application/json"}, )
# Only include 1080p+ streams quality_score = 0 url_lower = stream_url.lower() if "2160" in url_lower or "4k" in url_lower: quality_score = 2160 elif "1440" in url_lower: quality_score = 1440 elif "1080" in url_lower: quality_score = 1080 elif "720" in url_lower: quality_score = 720
# Try to detect quality from m3u8 playlist if quality_score == 0 and ".m3u8" in stream_url: try: pl_resp = await client.get(stream_url, headers=CLOUD_HEADERS) pl_text = pl_resp.text max_res = 0 for res_m in re.finditer(r'RESOLUTION=\s*\d+x(\d+)', pl_text, re.I): h = int(res_m.group(1)) if h > max_res: max_res = h if max_res > 0: quality_score = max_res except: pass
if quality_score < 1080: continue
# Quality label if quality_score >= 2160: qlabel = "2160p" elif quality_score >= 1440: qlabel = "1440p" elif quality_score >= 1080: qlabel = "1080p" else: qlabel = "Auto" if dec_resp.status_code != 200: errors.append(f"VidSrc: Decrypt failed HTTP {dec_resp.status_code}") return results, errors
results.append({ "source": f"VidSrc/srv{idx + 1}", "title": f"VidSrc Server {idx + 1}", "quality": qlabel, "language": "English", "url": stream_url, "type": "m3u8", "headers": CLOUD_HEADERS, }) dec_data = dec_resp.json() stream_urls = dec_data.get("result", []) if not isinstance(stream_urls, list) or not stream_urls: errors.append("VidSrc: No stream URLs after decryption") return results, errors
if not results: # Fallback: include lower quality streams too # Step 4: Process stream URLs for idx, stream_url in enumerate(stream_urls): if not stream_url: continue
quality = "Auto" url_lower = stream_url.lower() if "2160" in url_lower or "4k" in url_lower: quality = "2160p" elif "1440" in url_lower: quality = "1440p" elif "1080" in url_lower: quality = "1080p" elif "720" in url_lower: quality = "720p"
results.append({ "source": f"VidSrc/srv{idx + 1}", "title": f"VidSrc Server {idx + 1}", "quality": "Auto", "quality": quality, "language": "English", "url": stream_url, "type": "m3u8", "headers": CLOUD_HEADERS, "headers": { "Referer": "https://cloudnestra.com/", "Origin": "https://cloudnestra.com", }, })
if not results:5 unmodified lines return results, errors
# ===== Source Map =====
SOURCE_MAP = {21 unmodified lines "videasy": {"name": "Videasy", "fn": lambda tid, mt, s, e: scrape_videasy(tid, mt, s, e), "languages": ["English", "Multi"], "reliability": "medium"}, "vidsrc": {"name": "VidSrc", "fn": lambda tid, mt, s, e: scrape_vidsrc(tid, mt, s, e), "languages": ["English"], "reliability": "medium"}, "languages": ["English"], "reliability": "low", "note": "Cloudflare-blocked from datacenter IPs (vsrc.su/cloudnestra.com)"},}
DEFAULT_SOURCES = ["cinesu", "vidnest", "dooflix", "castle", "movieboxhindi", "netmirror", "vidsrc", "vidrock"]DEFAULT_SOURCES = ["cinesu", "vidnest", "dooflix", "castle", "movieboxhindi", "netmirror", "vidrock"]
# ===== Helper: Run scrapers =====86 unmodified lines for key, src in SOURCE_MAP.items()}, "default_sources": DEFAULT_SOURCES, "tips": [ "No source = default sources (cinesu, vidnest, dooflix, castle, movieboxhindi, netmirror, vidsrc, vidrock)", "No source = default sources (cinesu, vidnest, dooflix, castle, movieboxhindi, netmirror, vidrock)", "Best for Hindi: /movie/ID/allmovieland or /movie/ID/dooflix or /movie/ID/movieboxhindi or /movie/ID/castle", "Best for English: /movie/ID/cinesu or /movie/ID/vidrock or /movie/ID/videasy", "Best for French: /movie/ID/vidnest",__pycache__/main.cpython-312.pyc
main.py+83-124