Fixes another bug with retrieving all Dinosaur Comics

This commit is contained in:
2025-12-05 10:33:00 -07:00
parent 9e6b9c35c2
commit 7bc0f353f3
3 changed files with 14 additions and 13 deletions

View File

@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "comic_download" name = "comic_download"
version = "0.2.1" version = "0.2.2"
authors = [ authors = [
{name = "Markil 3", email = "markil3@singlepilot.net"} {name = "Markil 3", email = "markil3@singlepilot.net"}
] ]

View File

@@ -1,6 +1,6 @@
[metadata] [metadata]
name = comic_download name = comic_download
version = 0.2.1 version = 0.2.2
[options] [options]
package_dir= package_dir=

View File

@@ -64,17 +64,18 @@ class DinosaurComic(Comic):
self.strip_index = {} self.strip_index = {}
date_pat = re.compile(r'(\d+)(st|nd|rd|th)') date_pat = re.compile(r'(\d+)(st|nd|rd|th)')
for archive_month in archives: for archive_month in archives:
link_el = archive_month.find("a") for line_item in archive_month.find_all("li"):
if link_el: link_el = line_item.find("a")
parsed_index = urlparse(link_el["href"]) if link_el:
identifier = int(parse_qs(parsed_index.query)["comic"][0]) parsed_index = urlparse(link_el["href"])
date_str = link_el.get_text() identifier = int(parse_qs(parsed_index.query)["comic"][0])
date = datetime.datetime.strptime(date_pat.sub(r'\1', date_str), '%B %d, %Y').date() date_str = link_el.get_text()
self.strips.append({ date = datetime.datetime.strptime(date_pat.sub(r'\1', date_str), '%B %d, %Y').date()
"identifier": identifier, self.strips.append({
"date": date, "identifier": identifier,
"description": link_el.next_sibling.get_text()[2:] "date": date,
}) "description": link_el.next_sibling.get_text()[2:]
})
self.strips.sort(key=lambda x: x["date"]) self.strips.sort(key=lambda x: x["date"])
for i in range(len(self.strips)): for i in range(len(self.strips)):
self.strip_index[self.strips[i]["identifier"]] = i self.strip_index[self.strips[i]["identifier"]] = i