mirror of
https://github.com/redlib-org/redlib.git
synced 2025-05-04 20:30:37 +00:00
Add comment counter and other post improvements
This commit is contained in:
parent
6127f2a90c
commit
090ca1a140
8 changed files with 320 additions and 306 deletions
|
@ -72,7 +72,7 @@ async fn parse_post(json: &serde_json::Value) -> Post {
|
|||
let ratio: f64 = post["data"]["upvote_ratio"].as_f64().unwrap_or(1.0) * 100.0;
|
||||
|
||||
// Determine the type of media along with the media URL
|
||||
let (post_type, media) = media(&post["data"]).await;
|
||||
let (post_type, media, width, height) = media(&post["data"]).await;
|
||||
|
||||
// Build a post using data parsed from Reddit post API
|
||||
Post {
|
||||
|
@ -119,6 +119,11 @@ async fn parse_post(json: &serde_json::Value) -> Post {
|
|||
domain: val(post, "domain"),
|
||||
rel_time,
|
||||
created,
|
||||
comments: format_num(post["data"]["num_comments"].as_i64().unwrap_or_default()),
|
||||
media_width: width,
|
||||
media_height: height,
|
||||
thumbnail_width: post["data"]["thumbnail_width"].as_i64().unwrap_or_default(),
|
||||
thumbnail_height: post["data"]["thumbnail_height"].as_i64().unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue