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 lines11141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129914 unmodified lines131413151316131713181319132013211322132313241143132513261327132886 unmodified lines14151416141712361237141814191420142114221113 unmodified lines
return 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 TMDB info = 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, errors
async with httpx.AsyncClient(timeout=15, follow_redirects=True, headers={"User-Agent": UA}) as client:
# Step 1: Search on the site search_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 page movie_url = None import re as _re article_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 = None best_score = 0 title_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: continue if "/feed/" in link_m.group(1): continue
alt_m = alt_pattern.search(article) if not alt_m: continue
item_url = link_m.group(1) item_title = alt_m.group(1).strip()
# Simple scoring: exact match > starts with > contains item_lower = item_title.lower().replace(":", "").replace("-", " ").strip() score = 0 if item_lower == title_lower: score = 100 elif item_lower.startswith(title_lower) or title_lower.startswith(item_lower): score = 80 elif title_lower in item_lower: score = 60
# Year bonus if year and year in item_title: score += 10
if score > best_score: best_score = score best_match = item_url
if 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 ID page_resp = await client.get(best_match, headers={"Referer": f"{BASE}/"}) page_html = page_resp.text
post_id_match = re.search(r'postid-(\d+)', page_html) if not post_id_match: errors.append("HDMovie2: Could not find post ID") return results, errors
post_id = post_id_match.group(1)
# Step 3: Try servers (up to 4) via AJAX for 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: continue
try: ajax_data = ajax_resp.json() except: continue
embed_url = ajax_data.get("embed_url", "") if not embed_url: continue
embed_url = embed_url.replace("\/", "/")
# Try hdm2.ink player hdm2_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.text stream_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 player molop_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.text sniff_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.ru if "prvs.top" in embed_url or "ok.ru" in embed_url: continue
except Exception as e: errors.append(f"HDMovie2/srv{nume}: {str(e)}") continue
if 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", "vidrock"]DEFAULT_SOURCES = ["cinesu", "vidnest", "dooflix", "castle", "movieboxhindi", "netmirror", "hdmovie2", "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, vidrock)", "Best for Hindi: /movie/ID/dooflix or /movie/ID/movieboxhindi or /movie/ID/netmirror or /movie/ID/castle", "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