Handle articles without categories

This commit is contained in:
mtkennerly 2024-04-22 00:15:23 -04:00
parent baf3084f90
commit 378878c49e
No known key found for this signature in database
GPG key ID: E764BE00BE6E6408
4 changed files with 8 additions and 27 deletions

View file

@ -76,15 +76,14 @@ async fn is_game_article(query: &str) -> Result<bool, Error> {
{
let title = page["title"].as_str().ok_or(Error::WikiData("query.pages[].title"))?;
if title == query {
for category in page["categories"]
.as_array()
.ok_or(Error::WikiData("query.pages[].categories"))?
{
let category_name = category["title"]
.as_str()
.ok_or(Error::WikiData("query.pages[].categories[].title"))?;
if category_name == "Category:Games" {
return Ok(true);
if let Some(categories) = page["categories"].as_array() {
for category in categories {
let category_name = category["title"]
.as_str()
.ok_or(Error::WikiData("query.pages[].categories[].title"))?;
if category_name == "Category:Games" {
return Ok(true);
}
}
}
}