Skip to content

Commit 85561ad

Browse files
committed
Add thenationcryptic
1 parent 36a46c6 commit 85561ad

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

cryptics/config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@
6565
),
6666
["solutions", "annotations"],
6767
),
68+
# thenationcryptic only publishes solutions on blog posts titled "Solution"
69+
# (mainly for The Nation puzzles).
70+
"thenationcryptic": lambda known_urls: filter_strings_by_keyword(
71+
get_new_urls_from_nested_sitemaps(
72+
"https://thenationcryptic.blogspot.com/sitemap.xml",
73+
r"https://thenationcryptic.blogspot.com/sitemap.xml\?page=[0-9]*",
74+
known_urls,
75+
),
76+
["solution", "solutions"],
77+
),
6878
}
6979

7080

cryptics/utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ def filter_strings_by_keyword(strings: Iterable[str], keywords: Iterable[str]):
8686
"times-xwd-times": lambda _, soup: (
8787
search(r"^[A-Za-z ]*[0-9,]+", soup.find("title").text).group()
8888
),
89+
"thenationcryptic": lambda source_url, _: (
90+
search(r"no-[0-9]*", source_url).group().title().replace("-", " ")
91+
),
8992
}
9093

9194
PUZZLE_DATE_EXTRACTORS = {
@@ -106,6 +109,9 @@ def filter_strings_by_keyword(strings: Iterable[str], keywords: Iterable[str]):
106109
soup.find("div", "asset-meta asset-entry-date").text.strip()
107110
).strftime("%Y-%m-%d")
108111
),
112+
"thenationcryptic": lambda _, soup: (
113+
parser.parse(soup.find("h2", "date-header").text.strip()).strftime("%Y-%m-%d")
114+
),
109115
}
110116

111117

@@ -141,6 +147,7 @@ def _soup_to_puzzle_url(puzzle_url_regex: str) -> Callable[[Any, BeautifulSoup],
141147
),
142148
),
143149
("times-xwd-times", r"^https?://www.thetimes.co.uk/puzzles/.+"),
150+
("thenationcryptic", r"https?://www.thenation.com/article/.+"),
144151
]
145152
}
146153

0 commit comments

Comments
 (0)