Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,13 @@ impl Mediawiki {
if !image["missing"].is_null() {
return Ok(None);
}
let url = image["imageinfo"][0]["url"]
let lossy_url = image["imageinfo"][0]["url"]
.as_str()
.ok_or_else(|| Error::Json(image.clone()))?;
let url = format!("{}{}format=original", lossy_url,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we can probably add a line like this to make this simpler:

        request.arg("format", "original");

Probably add it around https://github.com/FTB-Gamepedia/mediawiki-rs/pull/8/changes#diff-b1a35a68f14e696205874893c07fd24fdb88882b47c23cc0e0c80a30c7d53759R152-R153 if I were to choose, but anywhere before the actual request happens should be fine.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The argument is not going on that request, because that's the request to get the image URL in the first place. It has to be added to the later request where we actually download the image.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that my approach of using format to append a string is not the best way. I have not done too much with Rust yet, so sorry if I don't know about every API method there is!
But yeah, @retep998 is right: the format=original parameter needs to be added to this request, not the one before, where only the JSON is being fetched

if lossy_url.contains('?') { '&' } else { '?' });
let mut response = loop {
let mut request = self.client.request(Method::GET, url);
let mut request = self.client.request(Method::GET, &url);
request = request.header(USER_AGENT, &*self.config.useragent);
let response = request.send()?;
if response.status() == StatusCode::OK {
Expand Down