Spaces:
Running
Running
Z User commited on
Commit ·
561be79
1
Parent(s): 59763d4
Add HDMovie2 scraper (Hindi/Bollywood), NetMirror stream verification (filters broken PV/HS)
Browse files1113 unmodified lines11141115111611171118111914 unmodified lines113411351136113711381139114011411142114311441145114686 unmodified lines123312341235123612371238123912401113 unmodified linesreturn results, errors# ===== Source Map =====SOURCE_MAP = {14 unmodified lines"languages": ["English", "Hindi", "Multi"], "reliability": "high"},"movieboxhindi": {"name": "MovieBoxHindi", "fn": lambda tid, mt, s, e: scrape_movieboxhindi(tid, mt, s, e),"languages": ["Hindi", "English"], "reliability": "high"},"netmirror": {"name": "NetMirror", "fn": lambda tid, mt, s, e: scrape_netmirror(tid, mt, s, e),"languages": ["Hindi", "English", "Multi"], "reliability": "high"},"videasy": {"name": "Videasy", "fn": lambda tid, mt, s, e: scrape_videasy(tid, mt, s, e),"languages": ["English", "Multi"], "reliability": "medium"},}DEFAULT_SOURCES = ["cinesu", "vidnest", "dooflix", "castle", "movieboxhindi", "netmirror", "vidrock"]# ===== Helper: Run scrapers =====86 unmodified linesfor key, src in SOURCE_MAP.items()},"default_sources": DEFAULT_SOURCES,"tips": ["No source = default sources (cinesu, vidnest, dooflix, castle, movieboxhindi, netmirror, vidrock)","Best for Hindi: /movie/ID/dooflix or /movie/ID/movieboxhindi or /movie/ID/netmirror or /movie/ID/castle","Best for English: /movie/ID/cinesu or /movie/ID/vidrock or /movie/ID/videasy","Best for French: /movie/ID/vidnest","Castle: Stremio aggregator, returns multiple streams from different providers",1113 unmodified lines11141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129914 unmodified lines13141315131613171318131913201321132213231324132513261327132886 unmodified lines141514161417141814191420142114221113 unmodified linesreturn results, errors# ===== HDMovie2 Scraper (Hindi/Hollywood Hindi Dubbed) =====async def scrape_hdmovie2(tmdb_id: int, media_type: str, season: int = None, episode: int = None):results = []errors = []try:BASE = "https://hdmovie2.com.se"CDN = "https://hdm2.ink"UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"# Get title from TMDBinfo = await get_tmdb_info(tmdb_id, media_type)title = info.get("title", "")year = info.get("year", "")if not title:errors.append("HDMovie2: Could not get title from TMDB")return results, errorsasync with httpx.AsyncClient(timeout=15, follow_redirects=True, headers={"User-Agent": UA}) as client:# Step 1: Search on the sitesearch_url = f"{BASE}/?s={title}"search_resp = await client.get(search_url, headers={"Referer": f"{BASE}/"})search_html = search_resp.text# Parse search results - find matching movie pagemovie_url = Noneimport re as _rearticle_pattern = _re.compile(r'<article[^>]*>(.*?)</article>', _re.DOTALL)link_pattern = _re.compile(r'href="(https://hdmovie2\.com\.se/movies/([^"]+)/)"')alt_pattern = _re.compile(r'alt="([^"]+)"')best_match = Nonebest_score = 0title_lower = title.lower().replace(":", "").replace("-", " ").strip()for article_match in article_pattern.finditer(search_html):article = article_match.group(1)link_m = link_pattern.search(article)if not link_m:continueif "/feed/" in link_m.group(1):continuealt_m = alt_pattern.search(article)if not alt_m:continueitem_url = link_m.group(1)item_title = alt_m.group(1).strip()# Simple scoring: exact match > starts with > containsitem_lower = item_title.lower().replace(":", "").replace("-", " ").strip()score = 0if item_lower == title_lower:score = 100elif item_lower.startswith(title_lower) or title_lower.startswith(item_lower):score = 80elif title_lower in item_lower:score = 60# Year bonusif year and year in item_title:score += 10if score > best_score:best_score = scorebest_match = item_urlif not best_match or best_score < 30:errors.append("HDMovie2: No matching result found")return results, errors# Step 2: Get the movie page to extract post IDpage_resp = await client.get(best_match, headers={"Referer": f"{BASE}/"})page_html = page_resp.textpost_id_match = re.search(r'postid-(\d+)', page_html)if not post_id_match:errors.append("HDMovie2: Could not find post ID")return results, errorspost_id = post_id_match.group(1)# Step 3: Try servers (up to 4) via AJAXfor nume in range(1, 5):try:ajax_resp = await client.post(f"{BASE}/wp-admin/admin-ajax.php",data=f"action=doo_player_ajax&post={post_id}&nume={nume}&type=movie",headers={"Referer": best_match,"Content-Type": "application/x-www-form-urlencoded","User-Agent": UA,},)if ajax_resp.status_code != 200:continuetry:ajax_data = ajax_resp.json()except:continueembed_url = ajax_data.get("embed_url", "")if not embed_url:continueembed_url = embed_url.replace("\/", "/")# Try hdm2.ink playerhdm2_match = re.search(r'src="(https://hdm2\.ink/play\?v=[^"]+)"', embed_url)if hdm2_match:player_resp = await client.get(hdm2_match.group(1), headers={"Referer": f"{BASE}/"})player_html = player_resp.textstream_match = re.search(r'data-stream-url="([^"]+)"', player_html)if stream_match:stream_path = stream_match.group(1).replace("&", "&")final_url = f"{CDN}{stream_path}"if ".m3u8" not in final_url:final_url += "#index.m3u8"results.append({"source": f"HDMovie2/srv{nume}","title": "Hindi Dubbed HD","quality": "1080p","language": "Hindi","url": final_url,"type": "m3u8","headers": {"Referer": f"{CDN}/","Origin": CDN,"User-Agent": UA,},})break# Try molop.art playermolop_match = re.search(r'src="(https://molop\.art/watch\?v=[^"]+)"', embed_url)if molop_match:molop_resp = await client.get(molop_match.group(1), headers={"Referer": f"{BASE}/"})molop_html = molop_resp.textsniff_match = re.search(r'sniff\s*\(\s*["'][^"']+["']\s*,\s*["'][^"']+["']\s*,\s*["']([a-f0-9]+)["']', molop_html)if sniff_match:hash_val = sniff_match.group(1)m3u8_url = f"https://molop.art/m3u8/1/{hash_val}/master.m3u8?s=1&cache=1"results.append({"source": f"HDMovie2/molop{nume}","title": "Hindi Dubbed HD","quality": "1080p","language": "Hindi","url": m3u8_url,"type": "m3u8","headers": {"Referer": "https://molop.art/","Origin": "https://molop.art","User-Agent": UA,},})break# Skip prvs.top and ok.ruif "prvs.top" in embed_url or "ok.ru" in embed_url:continueexcept Exception as e:errors.append(f"HDMovie2/srv{nume}: {str(e)}")continueif not results:errors.append("HDMovie2: No working streams found")except Exception as e:errors.append(f"HDMovie2: {str(e)}")return results, errors# ===== Source Map =====SOURCE_MAP = {14 unmodified lines"languages": ["English", "Hindi", "Multi"], "reliability": "high"},"movieboxhindi": {"name": "MovieBoxHindi", "fn": lambda tid, mt, s, e: scrape_movieboxhindi(tid, mt, s, e),"languages": ["Hindi", "English"], "reliability": "high"},"hdmovie2": {"name": "HDMovie2", "fn": lambda tid, mt, s, e: scrape_hdmovie2(tid, mt, s, e),"languages": ["Hindi", "English"], "reliability": "medium"},"netmirror": {"name": "NetMirror", "fn": lambda tid, mt, s, e: scrape_netmirror(tid, mt, s, e),"languages": ["Hindi", "English", "Multi"], "reliability": "high"},"videasy": {"name": "Videasy", "fn": lambda tid, mt, s, e: scrape_videasy(tid, mt, s, e),"languages": ["English", "Multi"], "reliability": "medium"},}DEFAULT_SOURCES = ["cinesu", "vidnest", "dooflix", "castle", "movieboxhindi", "netmirror", "hdmovie2", "vidrock"]# ===== Helper: Run scrapers =====86 unmodified linesfor key, src in SOURCE_MAP.items()},"default_sources": DEFAULT_SOURCES,"tips": ["No source = default sources (cinesu, vidnest, dooflix, castle, movieboxhindi, netmirror, hdmovie2, vidrock)","Best for Hindi: /movie/ID/dooflix or /movie/ID/movieboxhindi or /movie/ID/hdmovie2 or /movie/ID/castle","Best for English: /movie/ID/cinesu or /movie/ID/vidrock or /movie/ID/videasy","Best for French: /movie/ID/vidnest","Castle: Stremio aggregator, returns multiple streams from different providers",
main.py+185-3