From f22587d4a0dffb4c8da7abef3042923b2bbf0180 Mon Sep 17 00:00:00 2001 From: Tyler Hallada Date: Tue, 18 Jan 2022 17:03:22 -0500 Subject: [PATCH] Handle missing category_id in scraper --- src/nexus_scraper.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/nexus_scraper.rs b/src/nexus_scraper.rs index ff69a40..ae2b260 100644 --- a/src/nexus_scraper.rs +++ b/src/nexus_scraper.rs @@ -100,13 +100,12 @@ impl ModListResponse { .next() .expect("Missing category link for mod"); let category_id = match category_elem.value().attr("href") { - Some(href) => Some( - href.split("/") - .nth(6) - .expect("Missing category id for mod") - .parse::() - .expect("Failed to parse category id"), - ), + Some(href) => href + .split("/") + .nth(6) + .expect("Missing category id for mod") + .parse::() + .ok(), None => None, }; let category_name = category_elem.text().next(); @@ -147,7 +146,6 @@ impl ModListResponse { .next() .expect("Missing last update text for mod") .trim(); - dbg!(&first_upload_at); let first_upload_at = NaiveDate::parse_from_str(first_upload_at, "%d %b %Y") .expect("Cannot parse first upload date"); let last_update_date_text = right