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

@ -36,13 +36,13 @@ class Time(datetime):
@classmethod
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
cleaned_str = re.sub(pattern, "", s).strip()
cleaned_str = pattern.sub("", s).strip()
if fmt:
dt = datetime.strptime(cleaned_str, fmt)
@ -99,8 +99,10 @@ class Leagues:
return (None, self.live_img)
def is_valid(self, event: str, league: str) -> bool:
if match := re.search(r"(\-|vs.?|at)", event):
t1, t2 = event.split(match[1])
pattern = re.compile(r"\s+(?:-|vs\.?|at)\s+", flags=re.IGNORECASE)
if pattern.search(event):
t1, t2 = re.split(pattern, event)
return any(t in self.teams(league) for t in (t1.strip(), t2.strip()))