Spaces:
Running
Running
Z User commited on
Commit ·
0db2d27
1
Parent(s): d722b8e
v6.1: Fix NetMirror - multi-match for TV shows, remove freecdn2 CDN check, PrimeVideo/Hotstar now work
Browse filesFiles changed (2)
971 unmodified lines972973974975976977975976977978979980981982981982983984985986987988989990991992993994995996983984985986987988989990991992993994999100010011002995996997998999100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371000100110021003100410051006103910071008100910101011104110421043104410451046101210131014101510161017101810191020102110221023104810491050105110521053105410551056102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710589 unmodified lines1068106910701072107310711072107310741075107710781076107710801081108210831084108510861078107910803 unmodified lines10841085108610961087108810891090971 unmodified lines return service_results, [f"{svc_name}: Search returned non-JSON"]
search_results = search_data.get("searchResult", []) # Fuzzy match: exact first, then starts-with, then contains match = None title_lower = title.lower() # Collect ALL matches ranked by relevance title_lower = title.lower().strip() exact_matches = [] starts_matches = [] contains_matches = [] for item in search_results: item_title = item.get("t", "").strip().lower() if item_title == title_lower: match = item break if not match: for item in search_results: item_title = item.get("t", "").strip().lower() if item_title.startswith(title_lower) or title_lower.startswith(item_title): match = item break if not match: for item in search_results: item_title = item.get("t", "").strip().lower() if title_lower in item_title or item_title in title_lower: match = item break
if not match or not match.get("id"): exact_matches.append(item) elif item_title.startswith(title_lower) or title_lower.startswith(item_title): starts_matches.append(item) elif title_lower in item_title or item_title in title_lower: contains_matches.append(item) # Try matches in order of relevance all_matches = exact_matches + starts_matches + contains_matches if not all_matches: return service_results, [f"{svc_name}: No match found"]
net_id = match["id"] final_id = net_id
# For TV, drill down to season/episode # For TV shows, try each match until we find one with seasons final_id = None if media_type == "tv": s = season or 1 e = episode or 1
post_resp = await client.get(f"{api_base}/post.php?id={net_id}", headers=headers) if post_resp.status_code != 200: return service_results, [f"{svc_name}: Post HTTP {post_resp.status_code}"]
try: post_data = post_resp.json() except: return service_results, [f"{svc_name}: Post returned non-JSON"]
seasons = post_data.get("season", []) target_term = f"Season {s}" season_entry = None for se in seasons: if se.get("s", "").__str__().find(target_term) >= 0: season_entry = se break
if not season_entry or not season_entry.get("id"): return service_results, [f"{svc_name}: Season {s} not found"]
season_id = season_entry["id"] episode_id = None page = 1
while not episode_id and page < 10: ep_resp = await client.get( f"{api_base}/episodes.php?id={season_id}&page={page}", headers=headers ) if ep_resp.status_code != 200: break for match_item in all_matches: net_id = match_item.get("id") if not net_id: continue try: ep_data = ep_resp.json() post_resp = await client.get(f"{api_base}/post.php?id={net_id}", headers=headers) if post_resp.status_code != 200: continue post_data = post_resp.json() except: break
episodes_list = ep_data.get("episodes", []) for ep in episodes_list: if str(ep.get("ep", "")) == str(e): episode_id = ep.get("id") continue seasons = post_data.get("season", []) if not seasons: continue # This match has no seasons, try next target_term = f"Season {s}" season_entry = None for se in seasons: if target_term in se.get("s", "").__str__(): season_entry = se break
if ep_data.get("nextPageShow") != "1": break page += 1
if not episode_id: return service_results, [f"{svc_name}: S{s}E{e} not found"]
final_id = episode_id if not season_entry or not season_entry.get("id"): continue # No matching season, try next match season_id = season_entry["id"] episode_id = None page = 1 while not episode_id and page < 10: ep_resp = await client.get(f"{api_base}/episodes.php?id={season_id}&page={page}", headers=headers) try: ep_data = ep_resp.json() except: break episodes = ep_data.get("episodes", []) for ep_item in episodes: if str(ep_item.get("ep", "")) == str(e): episode_id = ep_item.get("id") break if int(ep_data.get("nextPageShow", 0)) != 1: break page += 1 if episode_id: final_id = episode_id break # Found a working match! if not final_id: return service_results, [f"{svc_name}: No match with Season {s} Episode {e}"] else: # For movies, just use the best match final_id = all_matches[0].get("id")
# Get the actual stream player_resp = await client.get(f"{api_base}/player.php?id={final_id}", headers=headers)9 unmodified lines if not video_link: return service_results, [f"{svc_name}: No video link"]
# Verify the m3u8 stream is actually playable # PrimeVideo/Hotstar use freecdn2.top which returns 404 on segments # Verify the m3u8 stream is playable # CDN has migrated to tv.imgcdn.kim which works for all services if ".m3u8" in video_link: try: verify_resp = await client.get(video_link, headers=headers) verify_text = verify_resp.text if "#EXTM3U" not in verify_text: if "#EXTM3U" not in verify_resp.text: return service_results, [f"{svc_name}: Master playlist unreachable"] # Check for broken CDN - freecdn2.top segments always return 404 if "freecdn2.top" in verify_text: seg_match = re.search(r'(https?://[^\s"]+\.m3u8[^\s"]*)', verify_text) if seg_match: seg_resp = await client.get(seg_match.group(1).split('"')[0].split()[0], headers=headers) if seg_resp.status_code == 404: return service_results, [f"{svc_name}: Stream unplayable (CDN segments 404)"] except: pass
3 unmodified lines if q_match: quality = q_match.group(1) + "p"
lang = "Hindi" if svc_code == "hs" else "English" lang = detect_language(svc_name + " " + video_link)
service_results.append({ "source": f"NetMirror/{svc_name}",__pycache__/main.cpython-312.pyc
main.py+74-83