Fix bug that broke partial metadata parsing

This commit is contained in:
froge 2023-10-08 04:06:25 +10:00
parent 7d379448ff
commit 4f5e01802f
Signed by: froge
GPG key ID: A825E09930271BFA

View file

@ -57,8 +57,15 @@ pub fn parse_metadata(page: &str) -> Option<Embed> {
meta_description = desc.value().attr("content").unwrap().to_string(); meta_description = desc.value().attr("content").unwrap().to_string();
} }
// Handle logging of parse failures // Handle logging of parse failures
(Some(_), None) => warn!("Failed to parse description HTML"), // and set values to whatever we *did* manage to scrape
(None, Some(_)) => warn!("Failed to parse title HTML"), (Some(title), None) => {
warn!("Failed to parse description HTML");
meta_title = title.text().collect();
}
(None, Some(desc)) => {
warn!("Failed to parse title HTML");
meta_description = desc.value().attr("content").unwrap().to_string();
}
} }
Some(Embed::new(meta_title, meta_description)) Some(Embed::new(meta_title, meta_description))