mirror of
https://github.com/redlib-org/redlib.git
synced 2025-06-07 15:17:47 +00:00
Fix GIFs
This commit is contained in:
parent
89fa0d5489
commit
eb9a0dcb4a
5 changed files with 25 additions and 20 deletions
11
src/utils.rs
11
src/utils.rs
|
@ -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";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue