This commit is contained in:
spikecodes 2021-01-12 19:52:02 -08:00
parent 89fa0d5489
commit eb9a0dcb4a
5 changed files with 25 additions and 20 deletions

View file

@ -169,10 +169,15 @@ pub async fn media(data: &serde_json::Value) -> (String, String) {
format_url(data["secure_media"]["reddit_video"]["fallback_url"].as_str().unwrap_or_default())
} else if data["post_hint"].as_str().unwrap_or("") == "image" {
let preview = data["preview"]["images"][0].clone();
post_type = "image";
match preview["variants"]["mp4"].as_object() {
Some(gif) => format_url(gif["source"]["url"].as_str().unwrap_or_default()),
None => format_url(preview["source"]["url"].as_str().unwrap_or_default()),
Some(gif) => {
post_type = "gif";
format_url(gif["source"]["url"].as_str().unwrap_or_default())
},
None => {
post_type = "image";
format_url(preview["source"]["url"].as_str().unwrap_or_default())
},
}
} else if data["is_self"].as_bool().unwrap_or_default() {
post_type = "self";