This commit is contained in:
doms9 2025-10-06 19:53:10 -04:00
parent b0634d6724
commit 00000d9f37
2 changed files with 8 additions and 6 deletions

View file

@ -35,7 +35,7 @@ async def main() -> None:
asyncio.create_task(tvpass.scrape(network.client)), asyncio.create_task(tvpass.scrape(network.client)),
] ]
await asyncio.gather(*tasks, return_exceptions=True) await asyncio.gather(*tasks)
additions = ( additions = (
fstv.urls fstv.urls

View file

@ -36,13 +36,13 @@ class Time(datetime):
@classmethod @classmethod
def from_str(cls, s: str, fmt: str | None = None) -> "Time": def from_str(cls, s: str, fmt: str | None = None) -> "Time":
pattern = r"\b(ET|UTC|EST|EDT)\b" pattern = re.compile(r"\b(ET|UTC|EST|EDT)\b")
match = re.search(pattern, s) match = pattern.search(s)
tz = ZONES.get(match[1]) if match else cls.TZ tz = ZONES.get(match[1]) if match else cls.TZ
cleaned_str = re.sub(pattern, "", s).strip() cleaned_str = pattern.sub("", s).strip()
if fmt: if fmt:
dt = datetime.strptime(cleaned_str, fmt) dt = datetime.strptime(cleaned_str, fmt)
@ -99,8 +99,10 @@ class Leagues:
return (None, self.live_img) return (None, self.live_img)
def is_valid(self, event: str, league: str) -> bool: def is_valid(self, event: str, league: str) -> bool:
if match := re.search(r"(\-|vs.?|at)", event): pattern = re.compile(r"\s+(?:-|vs\.?|at)\s+", flags=re.IGNORECASE)
t1, t2 = event.split(match[1])
if pattern.search(event):
t1, t2 = re.split(pattern, event)
return any(t in self.teams(league) for t in (t1.strip(), t2.strip())) return any(t in self.teams(league) for t in (t1.strip(), t2.strip()))