From a096b040a5bedbd4cf15685d0181a4ab2498e7b8 Mon Sep 17 00:00:00 2001 From: UrloMythus Date: Sat, 8 Feb 2025 22:15:40 +0100 Subject: [PATCH] Improved SkyStreaming Scraper --- Src/API/webru.py | 15 +++++---------- run.py | 9 ++++----- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/Src/API/webru.py b/Src/API/webru.py index 3b15197..4709ceb 100644 --- a/Src/API/webru.py +++ b/Src/API/webru.py @@ -66,7 +66,6 @@ async def get_stream_link(id,site,MFP_CREDENTIALS,client): mfp_url = MFP_CREDENTIALS[0] mfp_pass = MFP_CREDENTIALS[1] new_stream_url = f'{mfp_url}/proxy/hls/manifest.m3u8?api_password={mfp_pass}&d={stream_url}&h_Referer={Referer}&h_Origin={Origin}&h_User-Agent=Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F58.0.3029.110%20Safari%2F537.3' - return new_stream_url except Exception as e: return None @@ -88,14 +87,10 @@ async def get_skystreaming(id,client): if type(skystreaming_link) == list: for link in skystreaming_link: - m3u8_url,Host = await get_skystreaming_url(link,client) - m3u8_urls[m3u8_url] = Host - print(m3u8_urls) + m3u8_url,Host,Origin = await get_skystreaming_url(link,client) else: - m3u8_url,Host = await get_skystreaming_url(skystreaming_link,client) - m3u8_urls[m3u8_url] = Host - return m3u8_urls - + m3u8_url,Host,Origin = await get_skystreaming_url(skystreaming_link,client) + return m3u8_url,Host,Origin except Exception as e: print("SkyStreaming failed",e) return None,None @@ -111,12 +106,12 @@ async def get_skystreaming_url(skystreaming_link,client): Host = m3u8_url.replace("https://","").split("/")[0] return m3u8_url,Host response = await client.get(skystreaming_link, headers=headers, allow_redirects=True, impersonate = "chrome120") + Origin = response.url.split('/embed')[0] soup = BeautifulSoup(response.text, 'lxml', parse_only=SoupStrainer('source')) source_tag = soup.find('source') m3u8_url = source_tag.get('src') Host = m3u8_url.replace("https://","").split("/")[0] - print(Host) - return m3u8_url,Host + return m3u8_url,Host,Origin except Exception as e: print("SkyStreaming failed",e) return None,None diff --git a/run.py b/run.py index 77c5e69..497b1da 100644 --- a/run.py +++ b/run.py @@ -247,11 +247,10 @@ async def addon_stream(request: Request,config, type, id,): else: streams['streams'].append({'title':f"{Icon}Server {i} " + channel['title'],'url': item}) if id in skystreaming and SKY == "1": - urls = await get_skystreaming(id,client) - for url in urls: - i = i+1 - Host = urls[url] - streams['streams'].append({'title': f'{Icon}Server S {i}' + channel['title'], 'url': url, "behaviorHints": {"notWebReady": True, "proxyHeaders": {"request": {"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:127.0) Gecko/20100101 Firefox/127.0", "Accept": "*/*", "Accept-Language": "en-US,en;q=0.5", "Origin": f"https://skystreaming.{SKY_DOMAIN}", "DNT": "1", "Sec-GPC": "1", "Connection": "keep-alive", "Referer": f"https://skystreaming.{SKY_DOMAIN}/", "Sec-Fetch-Dest": "empty", "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "cross-site", "Pragma": "no-cache", "Cache-Control": "no-cache", "TE": "trailers","Host": Host}}}}) + url,Host,Sky_Origin = await get_skystreaming(id,client) + i = i+1 + if url: + streams['streams'].append({'title': f'{Icon}Server S {i}' + channel['title'], 'url': url, "behaviorHints": {"notWebReady": True, "proxyHeaders": {"request": {"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:127.0) Gecko/20100101 Firefox/127.0", "Accept": "*/*", "Accept-Language": "en-US,en;q=0.5", "Origin": Sky_Origin, "DNT": "1", "Sec-GPC": "1", "Connection": "keep-alive", "Referer": f"{Sky_Origin}/", "Sec-Fetch-Dest": "empty", "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "cross-site", "Pragma": "no-cache", "Cache-Control": "no-cache", "TE": "trailers","Host": Host}}}}) if MFP == "1": if id in webru_vary: i = i+1