speed and stuff

This commit is contained in:
blank X 2020-10-26 18:28:39 +07:00
parent f28aa893d8
commit 69a299495d
4 changed files with 12 additions and 19 deletions

View File

@ -20,12 +20,10 @@ pub async fn run(args: env::Args) {
exit(1);
}
for result in search_info.result {
let text;
if result.title.english != "" {
text = result.title.english;
} else {
text = result.title.japanese;
let mut title = &result.title.english.unwrap_or_default();
if title == "" {
title = &result.title.japanese.as_ref().unwrap();
}
println!("{}: {}", result.id, text);
println!("{}: {}", result.id, &title);
}
}

View File

@ -21,11 +21,11 @@ pub async fn run(args: env::Args) {
handles.push(tokio::spawn(async move {
let sauce_info = utils::get_sauce_info(cloned_client, sauce).await.unwrap();
let mut text = format!("Sauce: {}\nTitle: ", sauce_info.id);
let english_title = sauce_info.title.english;
let japanese_title = sauce_info.title.japanese;
if english_title != "" {
let japanese_title = &sauce_info.title.japanese.unwrap_or_default();
let english_title = &sauce_info.title.english.unwrap_or_default();
if english_title.as_str() != "" {
text.push_str(&english_title);
if japanese_title != "" {
if japanese_title.as_str() != "" {
text.push_str(&format!("\nJapanese Title: {}", &japanese_title));
}
} else {

View File

@ -2,9 +2,9 @@ use serde::Deserialize;
#[derive(Deserialize, Debug)]
pub struct GalleryTitleInfo {
pub english: String,
pub japanese: String,
pub pretty: String,
pub english: Option<String>,
pub japanese: Option<String>,
pub pretty: Option<String>,
}
#[derive(Deserialize, Debug)]
@ -17,7 +17,7 @@ pub struct GalleryImageInfo {
#[derive(Deserialize, Debug)]
pub struct GalleryImagesInfo {
pub pages: Vec<GalleryImageInfo>,
pub cover: GalleryImageInfo,
pub cover: GalleryImageInfo,
pub thumbnail: GalleryImageInfo
}

View File

@ -13,11 +13,6 @@ fn fix_gallery(body: &mut serde_json::Value) -> Result<(), serde_json::Error> {
body["id"].as_str().unwrap().parse::<usize>().unwrap()
);
}
for title in ["english", "japanese", "pretty"].iter() {
if body["title"][title].is_null() {
body["title"][title] = serde_json::json!("")
}
}
Ok(())
}