import httpx import random from dictionaries import webru_vary,webru_dlhd Referer = "https://ilovetoplay.xyz/" Origin = "https://ilovetoplay.xyz" headers = { "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", "Accept-Encoding": "gzip, deflate, br, zstd", "Origin": Origin, "DNT": "1", "Sec-GPC": "1", "Connection": "keep-alive", "Referer": Referer, "Sec-Fetch-Dest": "empty", "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "cross-site", "Pragma": "no-cache", "Cache-Control": "no-cache", } async def get_stream_link(id,site,client): if site == "dlhd": m3u8_url = webru_dlhd[id] elif site == "vary": m3u8_url = webru_vary[id] response = await client.get(m3u8_url, headers=headers, follow_redirects=False) if response.status_code == 301: stream_url = response.headers.get("Location", "") return stream_url,Referer,Origin async def webru(id,site,client): stream_url, Referer,Origin = await get_stream_link(id,site,client) mediaproxy = ["https://lorempizza-mediamammamia1.hf.space/","https://lorempizza-mediamammamia2.hf.space/", "https://lorempizza-mediamammamia3.hf.space/", "https://lorempizza-mediamammamia4.hf.space/", "https://lorempizza-mediamammamia5.hf.space/", "https://lorempizza-mediamammamia6.hf.space/", "https://lorempizza-mediamammamia7.hf.space/", "https://lorempizza-mediamammamia8.hf.space/", "https://lorempizza-mediamammamia9.hf.space/", "https://lorempizza-mediamammamia10.hf.space/"] medialink = random.choice(mediaproxy) new_stream_url = f'{medialink}proxy/hls?key_url=https%3A%2F%2Fkey.mizhls.ru%2F&api_password=MammaMia!09&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' print(new_stream_url) return new_stream_url