Spaces:
Paused
Paused
from bs4 import BeautifulSoup | |
import httpx | |
tivu = { | |
"dazn-zona-a": "801", | |
} | |
""" | |
"rai-1": "3401", | |
"rai-2": "3402", | |
"rai-3": "3403", | |
"rete-4": "123", | |
"canale-5": "122", | |
"italia-1": "121", | |
"la7": "79", | |
"tv8": "7260", | |
"nove": "4323", | |
"rai-4": "3405", | |
"rai-movie": "3406", | |
"rai-premium": "8522", | |
"mediaset-extra": "129", | |
"cielo": "4120", | |
"rai-sport": "17714", | |
"rai-news": "17711", | |
"dmax": "15202", | |
"real-time": "15201", | |
"focus": "134", | |
"giallo": "4322", | |
"topcrime": "132", | |
"boing": "126", | |
"cartoonito": "133", | |
"k2": "15204", | |
"foodnetwork": "15203", | |
"hgtv": "4334", | |
"solocalcio": "4996" , | |
"euronews": "2017", | |
"rai-4k": "3407", | |
""" | |
convert_bho_1 = { | |
"euronews": "PlutoEuronews.it", | |
"cartoonito": "cartoonito", | |
"sky-tg-24": "skytg24", | |
"frisbee": "frisbee", | |
"hgtv": "hgtv", | |
"k2": "k2", | |
"supertennis": "supertennis", | |
"solocalcio": "sportitaliasolocalcio", | |
"sportitalia": "sportitalia", | |
"sportitalia24": "RakutenSportItalia.it", | |
"rsi-la-2": "rsila2", | |
"baby-shark-tv": "RakutenBabySharkTv.it", | |
"adrenaline-movies": "RakutenFullMoon.it", | |
"adrenaline-movies": "RakutenBizzarroMovies.it", | |
"cinema-italiano": "RakutenCinemaItalianoRakutenTv.it", | |
"le-vite-degli-altri": "RakutenLeViteDegliAltri.it", | |
"dark-matter": "RakutenDarkMatterItNew.it", | |
"cine-western": "RakutenWesternEPeplum.it", | |
"serie-crime": "RakutenCrimeSeriesItRakutenTv.it", | |
"filmrise-sci-fi": "RakutenFuelTvNew.it", | |
"doctor-who": "RakutenBbcDoctorWho.it", | |
"bbc-drama": "RakutenBbcDrama.it", | |
"documentari": "RakutenDocumentaries.it", | |
"house-of-docs": "RakutenHouseOfDocs.it", | |
"the-asylum": "PlutoTheAsylum.it", | |
"western": "PlutoTvWestern.it", | |
"consulenze-illegali": "PlutoConsulenzeIllegaliItPlus.it" | |
} | |
convert_bho_2 = { | |
"la7": "La 7", | |
"rai-1": "Rai 1", | |
"rai-2": "Rai 2", | |
"rai-3": "Rai 3", | |
"rai-4": "Rai 4", | |
"rai-premium": "Rai Premium", | |
"rai-movie": "Rai Movie", | |
"rai-sport": "Rai Sport", | |
"rete-4": "Rete 4", | |
"canale-5": "Canale 5", | |
"italia-1": "Italia 1", | |
"topcrime": "Top Crime", | |
"mediaset-extra": "Mediaset Extra", | |
"focus": "Focus", | |
"boing": "Boing", | |
"history": "History", | |
"comedy-central": "Comedy Central", | |
"tv8": "TV 8", | |
"cielo": "Cielo", | |
"sky-cinema-action": "Sky Cinema Action", | |
"sky-arte": "Sky Arte FHD", | |
"sky-atlantic": "Sky Atlantic", | |
"sky-cinema-collection": "Sky Cinema Collection", | |
"sky-cinema-comedy": "Sky Cinema Comedy", | |
"sky-cinema-drama": "Sky Cinema Drama", | |
"sky-cinema-due": "Sky Cinema Due", | |
"sky-cinema-family": "Sky Cinema Family", | |
"sky-cinema-romance": "Sky Cinema Romance", | |
"sky-cinema-suspence": "Sky Cinema Suspence", | |
"sky-cinema-uno": "Sky Cinema Uno", | |
"sky-uno": "Sky Uno", | |
"sky-sport-24": "Sky Sport", | |
"sky-sport-uno": "Sky Sport Uno", | |
"sky-sport-f1": "Sky Sport F1", | |
"sky-sport-motogp": "Sky Sport MotoGP", | |
"sky-sport-arena": "Sky Sport Arena", | |
"sky-sport-nba": "Sky Sport NBA", | |
"eurosport-1": "Eurosport 1", | |
"eurosport-2": "Eurosport 2", | |
"dmax": "Dmax", | |
"foodnetwork": "Food Network", | |
"giallo": "Giallo", | |
"nove": "Nove", | |
"realtime": "Real Time", | |
} | |
async def tivu_get(id): | |
try: | |
cookies = { | |
'ASP.NET_SessionId': 'p2fk5silp5mjgtx0j5chjrh3', | |
} | |
ik = tivu[id] | |
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', | |
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', | |
'X-Requested-With': 'XMLHttpRequest', | |
'Origin': 'https://www.tivu.tv', | |
'DNT': '1', | |
'Sec-GPC': '1', | |
'Connection': 'keep-alive', | |
'Referer': 'https://www.tivu.tv/schedasat-rai1.html', | |
# 'Cookie': 'ASP.NET_SessionId=p2fk5silp5mjgtx0j5chjrh3', | |
'Sec-Fetch-Dest': 'empty', | |
'Sec-Fetch-Mode': 'cors', | |
'Sec-Fetch-Site': 'same-origin', | |
'Pragma': 'no-cache', | |
'Cache-Control': 'no-cache', | |
} | |
data = { | |
'ik': ik | |
} | |
async with httpx.AsyncClient() as client: | |
response = await client.post('https://www.tivu.tv/getPrograms.ashx', cookies=cookies, headers=headers, data=data) | |
soup = BeautifulSoup(response.text,'lxml') | |
tr_element = soup.find('tr', class_='in_onda') | |
hour_range = tr_element.find_all('td')[0].text.strip() | |
program_name = tr_element.find_all('td')[1].text.strip() | |
description = hour_range + " " + program_name | |
print(description) | |
return description | |
except Exception as e: | |
print(e) | |
return None | |
async def epg_guide(id): | |
try: | |
async with httpx.AsyncClient() as client: | |
if id in convert_bho_1: | |
id = convert_bho_1[id] | |
response = await client.get(f"https://lorempizza-boh.hf.space/{id}/now") | |
elif id in convert_bho_2: | |
id = convert_bho_2[id] | |
response = await client.get(f"https://mammamia-urlo-boh2.hf.space/{id}/now") | |
data = response.json() | |
description = data['description'].replace("- EPG by epg-guide.com","").replace("No description","") | |
title = data['title'] | |
print(description,title) | |
return description,title | |
except Exception as e: | |
print(e) | |
description = f'Watch {id}' | |
title = "" | |
return description,title | |