Working version
This commit is contained in:
50
run.py
Normal file
50
run.py
Normal file
@@ -0,0 +1,50 @@
|
||||
# run.py
|
||||
## Download EPG ##
|
||||
import requests
|
||||
from pathlib import Path
|
||||
from datetime import datetime, timedelta
|
||||
import os
|
||||
xml_url = os.getenv("XML_URL")
|
||||
import sys
|
||||
|
||||
DATA_DIR = Path("data")
|
||||
DATA_DIR.mkdir(parents=True, exist_ok=True)
|
||||
local_path = DATA_DIR / "epg.xml"
|
||||
|
||||
def download_epg():
|
||||
try:
|
||||
resp = requests.get(xml_url, timeout=30)
|
||||
resp.raise_for_status()
|
||||
local_path.write_bytes(resp.content)
|
||||
print(f"EPG saved to {local_path}")
|
||||
except Exception as e:
|
||||
print(f"Failed to download EPG: {e}", file=sys.stderr)
|
||||
# If EPG is required for later steps, you may want to sys.exit(1)
|
||||
|
||||
download_epg()
|
||||
|
||||
def run(mod):
|
||||
print(mod.upper())
|
||||
rc = os.system(f"python -m src.{mod}")
|
||||
if rc != 0:
|
||||
print(f"ERROR in {mod} (exit {rc})")
|
||||
|
||||
for mod in ["mlb", "epl", "ufc"]:
|
||||
run(mod)
|
||||
|
||||
##################
|
||||
##### SLEEPY #####
|
||||
##################
|
||||
|
||||
print(datetime.now())
|
||||
now = datetime.now()
|
||||
manana0 = datetime.now()+timedelta(days=1)
|
||||
manana = datetime(int(manana0.year),int(manana0.month),int(manana0.day),7,30)
|
||||
print('sleeping until '+str(manana))
|
||||
print(((manana-now).days*24*60*60)+((manana-now).seconds))
|
||||
time.sleep(((manana-now).days*24*60*60)+((manana-now).seconds))
|
||||
#del game_url
|
||||
#del main_soup
|
||||
|
||||
print(datetime.now())
|
||||
|
Reference in New Issue
Block a user