2022-04-03 19:11:11 +00:00
|
|
|
mod parse;
|
|
|
|
|
2022-02-25 17:24:24 +00:00
|
|
|
pub mod clipboard;
|
2022-01-22 21:02:51 +00:00
|
|
|
pub mod credits;
|
|
|
|
pub mod delete_image;
|
2022-01-23 12:05:32 +00:00
|
|
|
pub mod info_image;
|
2022-01-22 21:14:26 +00:00
|
|
|
pub mod upload_image;
|
2022-03-03 20:14:43 +00:00
|
|
|
pub mod webhook;
|
2022-01-23 12:05:32 +00:00
|
|
|
|
2022-04-03 19:11:11 +00:00
|
|
|
pub use parse::*;
|
|
|
|
|
2022-01-25 16:13:43 +00:00
|
|
|
use chrono::{prelude::DateTime, Utc};
|
2022-02-25 17:24:24 +00:00
|
|
|
use colored::Colorize;
|
2022-04-03 19:01:58 +00:00
|
|
|
use imgurs::ImageInfo;
|
2022-01-27 13:14:46 +00:00
|
|
|
use std::time::{Duration, UNIX_EPOCH};
|
2022-01-23 12:05:32 +00:00
|
|
|
|
2022-04-03 19:01:58 +00:00
|
|
|
// print image information from imgur
|
2022-05-18 18:52:47 +00:00
|
|
|
pub fn print_image_info(i: &ImageInfo) {
|
2022-04-03 19:01:58 +00:00
|
|
|
// format image upload date
|
2022-01-23 12:05:32 +00:00
|
|
|
let d = UNIX_EPOCH + Duration::from_secs(i.data.datetime.try_into().unwrap());
|
|
|
|
let datetime = DateTime::<Utc>::from(d);
|
|
|
|
let timestamp_str = datetime.format("%Y-%m-%d %H:%M:%S").to_string();
|
|
|
|
|
2022-04-03 19:01:58 +00:00
|
|
|
// image title
|
2022-01-23 12:05:32 +00:00
|
|
|
if i.data.title != None {
|
2022-05-18 18:52:47 +00:00
|
|
|
let title = i.data.title.clone();
|
|
|
|
|
2022-02-25 17:24:24 +00:00
|
|
|
println!(
|
|
|
|
"{} {}",
|
|
|
|
"title".green(),
|
2022-05-18 18:52:47 +00:00
|
|
|
title.unwrap_or_else(|| "unknown".to_string()).magenta()
|
2022-01-23 12:05:32 +00:00
|
|
|
);
|
|
|
|
}
|
2022-04-03 19:01:58 +00:00
|
|
|
|
|
|
|
// image description
|
2022-01-23 12:05:32 +00:00
|
|
|
if i.data.description != None {
|
2022-05-18 18:52:47 +00:00
|
|
|
let desc = i.data.description.clone();
|
|
|
|
|
2022-02-25 17:24:24 +00:00
|
|
|
println!(
|
|
|
|
"{} {}",
|
|
|
|
"description".green(),
|
2022-05-18 18:52:47 +00:00
|
|
|
desc.unwrap_or_else(|| "unknown".to_string()).magenta()
|
2022-01-23 12:05:32 +00:00
|
|
|
);
|
|
|
|
}
|
2022-04-03 19:01:58 +00:00
|
|
|
|
|
|
|
// image deletehas
|
2022-01-23 12:05:32 +00:00
|
|
|
if i.data.deletehash != None {
|
2022-05-18 18:52:47 +00:00
|
|
|
let delhash = i.data.deletehash.clone();
|
|
|
|
|
2022-02-25 17:24:24 +00:00
|
|
|
println!(
|
|
|
|
"{} {}",
|
|
|
|
"deletehash".green(),
|
2022-05-18 18:52:47 +00:00
|
|
|
delhash.unwrap_or_else(|| "unknown".to_string()).magenta()
|
2022-01-23 12:05:32 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-02-25 17:24:24 +00:00
|
|
|
println!("{} {}", "id".green(), i.data.id.magenta());
|
|
|
|
println!(
|
|
|
|
"{} {} {}",
|
|
|
|
"upload date".green(),
|
|
|
|
timestamp_str.magenta(),
|
|
|
|
"(UTC)".blue()
|
|
|
|
);
|
|
|
|
println!("{} {}", "type".green(), i.data.img_type.magenta());
|
|
|
|
println!("{} {}", "width".green(), i.data.width.to_string().magenta());
|
|
|
|
println!(
|
|
|
|
"{} {}",
|
|
|
|
"height".green(),
|
|
|
|
i.data.height.to_string().magenta()
|
|
|
|
);
|
|
|
|
println!(
|
|
|
|
"{} {} {}",
|
|
|
|
"size".green(),
|
|
|
|
(i.data.size / 1000).to_string().magenta(),
|
|
|
|
"KB".blue()
|
|
|
|
);
|
|
|
|
println!("{} {}", "views".green(), i.data.views.to_string().magenta());
|
|
|
|
println!(
|
|
|
|
"{} {}",
|
|
|
|
"bandwidth".green(),
|
|
|
|
i.data.bandwidth.to_string().magenta()
|
|
|
|
);
|
|
|
|
println!("{} {}", "link".green(), i.data.link.magenta());
|
2022-01-23 12:05:32 +00:00
|
|
|
}
|