forked from alicatesTEAM/Mfeed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
48 lines (34 loc) · 1.45 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import requests
import csv
ott_url = "https://ottcache.dof6.com/movistarplus/webplayer/OTT/contents/epg"
ott_csv_filepath = "ott.csv"
difusion_url = "https://ottcache.dof6.com/movistarplus/webplayer/DIFUSION/contents/epg"
difusion_csv_filepath = "difusion.csv"
def export_movistarEPG_to_csv(epg_url, filepath):
response = requests.get(epg_url)
if response.status_code == 200:
movistarEPG = response.json()
else:
print("ERROR: movistarEPG no disponible")
return
csv_data = []
for indice, grupo in enumerate(movistarEPG):
csv_data.append({
"Nombre": grupo.get("Nombre", "").replace("\t", "").replace("\n", ""),
"FormatoVideo": grupo.get("FormatoVideo", ""),
"CodCadenaTv": grupo.get("CodCadenaTv", ""),
"CasId": grupo.get("CasId", ""),
"PuntoReproduccion": grupo.get("PuntoReproduccion", ""),
})
# Define CSV headers
headers = ["Nombre", "FormatoVideo", "CodCadenaTv", "CasId", "PuntoReproduccion"]
# Write CSV data to file
with open(filepath, mode='w', newline='', encoding='utf-8') as file:
writer = csv.DictWriter(file, fieldnames=headers, delimiter=',')
writer.writeheader()
writer.writerows(csv_data)
print(f"movistarEPG exported to {filepath}")
def flujo_vaginal():
export_movistarEPG_to_csv(ott_url, ott_csv_filepath)
export_movistarEPG_to_csv(difusion_url, difusion_csv_filepath)
flujo_vaginal()