Skip to content

Commit

Permalink
Fix image downloading
Browse files Browse the repository at this point in the history
  • Loading branch information
retep998 committed Sep 23, 2023
1 parent a0838d8 commit 62d3c16
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,9 @@ impl Mediawiki {
request.arg("iiprop", "url");
let json = request.get()?;
let images = json["query"]["pages"]
.as_object()
.ok_or_else(|| Error::Json(json.clone()))?;
let image = images
.values()
.next()
.as_array()
.ok_or_else(|| Error::Json(json.clone()))?;
let image = images.first().ok_or_else(|| Error::Json(json.clone()))?;
if !image["missing"].is_null() {
return Ok(None);
}
Expand Down

0 comments on commit 62d3c16

Please sign in to comment.