Spaces:
Paused
Paused
Update app.py
Browse files39 unmodified lines40414243444546474818 unmodified lines67686970717273747576777879808182838485868788896 unmodified lines9697989910010140 unmodified lines14214314414539 unmodified linestitle = title_el.inner_text().strip() if title_el else "Unknown"poster_path = img_el.get_attribute("src") if img_el else ""# We need to get the ID or slug to build the direct URL# Since we can't easily get the href from the div, we'll use the click-and-capture-URL method# but we'll do it more carefully.movie_links.append({"title": title,"poster": poster_path18 unmodified linespage.wait_for_selector("h1", timeout=30000)time.sleep(3)detail_url = page.urlbody_text = page.inner_text("body")# Extract Direct Linkdirect_url = detail_url # Default# Look for any link that looks like a stream or download# We can also look for the specific pattern in the HTMLhtml_content = page.content()# Try to find links in the HTML that contain .mp4 or .mkvmp4_links = re.findall(r'https?://[^\s<>"]+\.(?:mp4|mkv)[^\s<>"]*', html_content)if mp4_links:direct_url = mp4_links[0]else:# Try to find stream linksstream_links = re.findall(r'https?://stream\.[^\s<>"]+', html_content)if stream_links:direct_url = stream_links[0].split('"')[0].split("'")[0]# Fix Poster URLposter_path = movie['poster']6 unmodified linesposter_url = poster_path# Extract Genre & Yeargenre = "N/A"if "Genre…." in body_text:genre = body_text.split("Genre….")[1].split("Duration")[0].strip()40 unmodified lines)else:st.warning("No data found. Please try again.")39 unmodified lines40414243444518 unmodified lines646566676869707172737475767778798081828384858687886 unmodified lines959697989910010140 unmodified lines14214314414514639 unmodified linestitle = title_el.inner_text().strip() if title_el else "Unknown"poster_path = img_el.get_attribute("src") if img_el else ""movie_links.append({"title": title,"poster": poster_path18 unmodified linespage.wait_for_selector("h1", timeout=30000)time.sleep(3)html_content = page.content()# --- ပိုမိုတိကျသော Movie Direct URL Extraction (Regex ပြင်ဆင်ချက်) ---direct_url = page.url # Default logic fall-back# HTML stream content ထဲက .mp4 သို့မဟုတ် .mkv ဗီဒီယိုလင့်ခ်ကို Quotes မတွေ့မချင်း အကုန်ရှာမယ်video_links = re.findall(r'(https?://[^\'"]+\.(?:mp4|mkv)[^\'"]*)', html_content, re.IGNORECASE)if video_links:direct_url = video_links[0]else:# .mp4 တိုက်ရိုက်မတွေ့ရင် stream လင့်ခ်တွေကို ကုတ်ကြည့်မယ်stream_links = re.findall(r'(https?://stream\.[^\'"]+)', html_content)if stream_links:direct_url = stream_links[0]# URL encoding တွေ (ဥပမာ %20, %28) ကွဲမထွက်သွားအောင် သန့်စင်ပေးခြင်းdirect_url = direct_url.strip().split('"')[0].split("'")[0]# -------------------------------------------------------------# Fix Poster URLposter_path = movie['poster']6 unmodified linesposter_url = poster_path# Extract Genre & Yearbody_text = page.inner_text("body")genre = "N/A"if "Genre…." in body_text:genre = body_text.split("Genre….")[1].split("Duration")[0].strip()40 unmodified lines)else:st.warning("No data found. Please try again.")
app.py+19-18