diff --git a/src/client.py b/src/client.py index e007173..bd1fdbc 100644 --- a/src/client.py +++ b/src/client.py @@ -159,6 +159,8 @@ def fetch_calendar(self, start_date: date, end_date: date) -> List[Tournament]: continue title = h3_tag.text.strip() + if title.startswith("Limited"): + continue event_url = urljoin(MTGO_ROOT_URL, a_tag.get("href", "")) date_str = time_tag.get("datetime", "") diff --git a/src/config.py b/src/config.py index 5a3a411..64170c3 100644 --- a/src/config.py +++ b/src/config.py @@ -12,6 +12,7 @@ "Vintage", "Pauper", "Commander", + "Premodern", ] SCRYFALL_BULK_URL = "https://api.scryfall.com/bulk-data" diff --git a/src/scraper.py b/src/scraper.py index 5e9e524..7edcd18 100644 --- a/src/scraper.py +++ b/src/scraper.py @@ -134,6 +134,11 @@ def _sync_tournament( if not t.date: t.date = today + if t.name and t.name.startswith("Limited"): + logger.info("Skipping Limited event: %s", t.name) + stats["skipped"] += 1 + return True + safe_filename = sanitize_filename(t.json_file or "unknown.json") target_dir = os.path.join( self.cache_root, diff --git a/tests/test_client.py b/tests/test_client.py index ee52bed..21e405d 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -132,6 +132,12 @@ def test_tournament_from_url(): t_duel = tournament_from_url(duel_url) assert t_duel.formats == "Commander" + premodern_url = ( + "https://www.mtgo.com/decklist/premodern-challenge-32-2026-09-1012854063" + ) + t_premodern = tournament_from_url(premodern_url) + assert t_premodern.formats == "Premodern" + def test_fetch_event_data_404_no_retry(): client = MTGOClient(max_retries=3) @@ -164,3 +170,41 @@ def test_fetch_event_data_with_request_delay(monkeypatch): client.fetch_event_data("https://www.mtgo.com/decklist/test") assert sleep_calls == [0.1] + + +def test_fetch_calendar_skips_limited_events(): + client = MTGOClient() + mock_resp = MagicMock() + mock_resp.status_code = 200 + mock_resp.text = """ + +
+