Spaces:
Running
Running
Z User commited on
Commit ·
86ad7da
1
Parent(s): 01d1f8d
Add AllMovieLand scraper (Hindi/Tamil/multi-audio), remove HDMovie2 from defaults (molop CDN 403)
Browse files1311 unmodified lines1312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151714 unmodified lines153215331534153515361537153815392 unmodified lines1542154315441343154515461547154886 unmodified lines16351636163714361437163816391640164116421311 unmodified lines
return results, errors
# ===== AllMovieLand Scraper (Hindi/Tamil/Multi via allmovieland.one) =====
async def scrape_allmovieland(tmdb_id: int, media_type: str, season: int = None, episode: int = None): results = [] errors = []
try: UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36" # Get title from TMDB info = await get_tmdb_info(tmdb_id, media_type) title = info.get("title", "") if not title: errors.append("AllMovieLand: Could not get title from TMDB") return results, errors
# Step 1: Search on allmovieland.one async with httpx.AsyncClient(timeout=15, follow_redirects=True, headers={"User-Agent": UA}, http2=False) as client: search_resp = await client.get( "https://allmovieland.one/index.php", params={"story": title, "do": "search", "subaction": "search"} ) search_html = search_resp.text
# Parse search results movie_url = None articles = re.findall(r'<article[^>]*>(.*?)</article>', search_html, re.DOTALL) title_lower = title.lower() for article in articles: link_m = re.search(r'href="([^"]+)"', article) h3_m = re.search(r'<h3[^>]*>(.*?)</h3>', article) if link_m and h3_m: item_title = h3_m.group(1).strip() item_url = link_m.group(1) # Simple match: exact or contains if item_title.lower() == title_lower or title_lower in item_title.lower(): movie_url = item_url break # Fuzzy: pick first result if no exact match if not movie_url and articles: for article in articles: link_m = re.search(r'href="([^"]+)"', article) if link_m: movie_url = link_m.group(1) break
if not movie_url: errors.append("AllMovieLand: No search results") return results, errors
# Step 2: Get movie page - extract player domain and ID movie_resp = await client.get(movie_url, headers={"Referer": "https://allmovieland.one/"}) movie_html = movie_resp.text
domain_m = re.search(r"AwsIndStreamDomain\s*=\s*'([^']+)'", movie_html) player_domain = domain_m.group(1).rstrip("/") if domain_m else None id_m = re.search(r"src:\s*'([^']+)'", movie_html) media_id = id_m.group(1) if id_m else None
if not player_domain or not media_id: errors.append("AllMovieLand: Could not extract player info") return results, errors
# Step 3: Get embed page - extract p3 JSON (file URL + CSRF key) embed_url = f"{player_domain}/play/{media_id}" embed_resp = await client.get(embed_url, headers={"Referer": movie_url}) embed_html = embed_resp.text
p3_m = re.search(r'let\s+p3\s*=\s*(\{.*?\});', embed_html) if not p3_m: errors.append("AllMovieLand: Could not find player data") return results, errors
p3 = json.loads(p3_m.group(1)) file_url = p3.get("file", "").replace("\\/", "/") csrf_key = p3.get("key", "")
if not file_url or not csrf_key: errors.append("AllMovieLand: Missing file URL or CSRF key") return results, errors
# Step 4: POST to get file list - use fresh client per attempt (burst) file_list = None post_headers = { "X-CSRF-TOKEN": csrf_key, "Referer": embed_url, "Origin": player_domain, "Accept": "application/json, text/plain, */*", "User-Agent": UA, }
for attempt in range(7): try: async with httpx.AsyncClient(timeout=10, follow_redirects=True, http2=False) as fresh_client: resp = await fresh_client.post(file_url, headers=post_headers) text = resp.text.strip() if text != "7" and text and text.startswith("["): file_list = json.loads(text.replace(",]", "]")) break except: pass
if not file_list: errors.append("AllMovieLand: Could not get file list after 7 attempts") return results, errors
# For movies: use all files. For TV: find matching season/episode target_files = [] if media_type == "movie": target_files = [f for f in file_list if f.get("file")] else: s = season or 1 e = episode or 1 # Find season season_data = None for item in file_list: item_title = item.get("title", "") s_m = re.search(r'Season\s*(\d+)', item_title, re.I) if s_m and int(s_m.group(1)) == s: season_data = item break # Also try by id if str(item.get("id")) == str(s): season_data = item break if season_data and season_data.get("folder"): # Find episode ep_data = None for ep_item in season_data["folder"]: ep_title = ep_item.get("title", "") e_m = re.search(r'Episode\s*(\d+)', ep_title, re.I) if e_m and int(e_m.group(1)) == e: ep_data = ep_item break if str(ep_item.get("episode")) == str(e): ep_data = ep_item break if ep_data and ep_data.get("folder"): target_files = [f for f in ep_data["folder"] if f.get("file")]
if not target_files: errors.append("AllMovieLand: No matching streams found") return results, errors
# Step 5: For each file, POST to get m3u8 URL (burst per file) for file_obj in target_files: file_path = file_obj.get("file", "").replace("~", "") stream_title = file_obj.get("title", "Stream") if not file_path: continue
playlist_url = f"{player_domain}/playlist/{file_path}.txt" m3u8_url = None for attempt in range(7): try: async with httpx.AsyncClient(timeout=10, follow_redirects=True, http2=False) as fresh_client: resp = await fresh_client.post(playlist_url, headers=post_headers) text = resp.text.strip() if text != "7" and text and text.startswith("http"): m3u8_url = text break except: pass
if m3u8_url: lang = detect_language(stream_title) quality = "Auto" q_m = re.search(r'(\d{3,4})p', stream_title) if q_m: quality = q_m.group(1) + "p"
results.append({ "source": f"AllMovieLand", "title": f"AllMovieLand - {stream_title}", "quality": quality, "language": lang, "url": m3u8_url, "type": "m3u8", "headers": { "Referer": f"{player_domain}/", "Origin": player_domain, "User-Agent": UA, }, })
if not results: errors.append("AllMovieLand: Could not resolve any m3u8 URLs")
except Exception as e: errors.append(f"AllMovieLand: {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"}, "allmovieland": {"name": "AllMovieLand", "fn": lambda tid, mt, s, e: scrape_allmovieland(tid, mt, s, e), "languages": ["Hindi", "Tamil", "Telugu", "English", "Multi"], "reliability": "medium"}, "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),2 unmodified lines "languages": ["English", "Multi"], "reliability": "medium"},}
DEFAULT_SOURCES = ["cinesu", "vidnest", "dooflix", "castle", "movieboxhindi", "netmirror", "hdmovie2", "vidrock"]DEFAULT_SOURCES = ["cinesu", "vidnest", "dooflix", "castle", "movieboxhindi", "netmirror", "allmovieland", "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, hdmovie2, vidrock)", "Best for Hindi: /movie/ID/dooflix or /movie/ID/movieboxhindi or /movie/ID/hdmovie2 or /movie/ID/castle", "No source = default sources (cinesu, vidnest, dooflix, castle, movieboxhindi, netmirror, allmovieland, 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", "Castle: Stremio aggregator, returns multiple streams from different providers",main.py+205-3