From b1f07280ca89544a719a444e978f5037a1078213 Mon Sep 17 00:00:00 2001 From: UrloMythus Date: Sun, 22 Sep 2024 22:00:21 +0200 Subject: [PATCH] Fix for WebRU --- Src/API/okru.py | 1 + Src/API/webru.py | 31 ++++++++++++++++++++----------- Src/Utilities/dictionaries.py | 5 +++-- config.json | 4 ++-- run.py | 4 +++- 5 files changed, 29 insertions(+), 16 deletions(-) diff --git a/Src/API/okru.py b/Src/API/okru.py index abacce7..3c2ab24 100644 --- a/Src/API/okru.py +++ b/Src/API/okru.py @@ -16,6 +16,7 @@ async def okru_get_url(id,client): metadata = json.loads(data['flashvars']['metadata']) m3u8_link = metadata['hlsMasterPlaylistUrl'] print("MammaMia: Found results for Okru") + print(m3u8_link) return m3u8_link except Exception as e: print("MammaMia: No results found for Okru") diff --git a/Src/API/webru.py b/Src/API/webru.py index fdcd428..d62ffce 100644 --- a/Src/API/webru.py +++ b/Src/API/webru.py @@ -52,16 +52,17 @@ async def webru(id,site,client): async def get_skystreaming(id,client): try: skystreaming_link = skystreaming[id] - m3u8_urls = [] + m3u8_urls = {} if type(skystreaming_link) == list: for link in skystreaming_link: m3u8_url,Host = await get_skystreaming_url(link,client) - m3u8_urls.append(m3u8_url) + m3u8_urls[m3u8_url] = Host + print(m3u8_urls) else: m3u8_url,Host = await get_skystreaming_url(skystreaming_link,client) - m3u8_urls.append(m3u8_url) - return m3u8_urls,Host + m3u8_urls[m3u8_url] = Host + return m3u8_urls except Exception as e: print("SkyStreaming failed",e) @@ -72,10 +73,18 @@ async def get_skystreaming(id,client): async def get_skystreaming_url(skystreaming_link,client): - response = await client.get(skystreaming_link, headers=headers, allow_redirects=True, impersonate = "chrome120") - 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 \ No newline at end of file + try: + if "hls" in skystreaming_link: + m3u8_url = skystreaming_link + Host = m3u8_url.replace("https://","").split("/")[0] + return m3u8_url,Host + response = await client.get(skystreaming_link, headers=headers, allow_redirects=True, impersonate = "chrome120") + 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 + except Exception as e: + print("SkyStreaming failed",e) + return None,None \ No newline at end of file diff --git a/Src/Utilities/dictionaries.py b/Src/Utilities/dictionaries.py index 0ca9bdc..a0c40bb 100644 --- a/Src/Utilities/dictionaries.py +++ b/Src/Utilities/dictionaries.py @@ -575,7 +575,7 @@ STREAM = { }, { "id": "sportitalia", - "title": ["Sportitalia"], + "title": "Sportitalia", "name": "", "genres": ["Sportitalia"], "poster": "https://upload.wikimedia.org/wikipedia/en/5/55/Sportitalia.jpg", @@ -860,7 +860,8 @@ skystreaming ={ "sky-sport-golf": "https://skystreaming.guru/embed/s9L5f", "eurosport-1": "https://skystreaming.guru/embed/Vyv99", "eurosport-2": "https://skystreaming.guru/embed/um8E5", - "dazn-zona-a": ["https://skystreaming.guru/embed/tIswJ","https://skystreaming.guru/embed/16U0s"], + "dazn-zona-a": ["https://skystreaming.guru/embed/tIswJ","https://hls.cls.autos/hls/serie/index.m3u8"], + "sportitalia": "https://skystreaming.guru/embed/zA9LP", } huhu = { "canale-5": "1101559666", diff --git a/config.json b/config.json index e3ef89f..5494aac 100644 --- a/config.json +++ b/config.json @@ -23,10 +23,10 @@ } }, "General":{ - "load_env": "1", + "load_env": "0", "HOST": "0.0.0.0", "PORT": "8080", - "HF": "0", + "HF": "1", "Public_Instance": "0", "MediaProxy": ["test"] } diff --git a/run.py b/run.py index 2bbf65c..70291f0 100644 --- a/run.py +++ b/run.py @@ -194,9 +194,11 @@ async def addon_stream(request: Request,config, type, id,): streams['streams'].append({'title':f"{HF}Server {i} " + channel['title'],'url': item}) if id in skystreaming: - urls,Host = await get_skystreaming(id,client) + urls = await get_skystreaming(id,client) for url in urls: i = i+1 + Host = urls[url] + print(url,Host) streams['streams'].append({'title': f'{HF}Server {i}', '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": "https://skystreaming.guru", "DNT": "1", "Sec-GPC": "1", "Connection": "keep-alive", "Referer": "https://skystreaming.guru/", "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 id in webru_vary: