Removes the TUI in favor of event based logging #15
1 changed files with 33 additions and 9 deletions
|
@ -4,7 +4,7 @@ use std::ops::Sub;
|
||||||
use chrono::{DateTime, Duration, Utc};
|
use chrono::{DateTime, Duration, Utc};
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use crate::{HTTP_CLIENT};
|
use crate::{HTTP_CLIENT, write_error};
|
||||||
use crate::jnovel::PartInfo::{NoParts, Part};
|
use crate::jnovel::PartInfo::{NoParts, Part};
|
||||||
use crate::jnovel::PostInfo::{Chapter, Volume};
|
use crate::jnovel::PostInfo::{Chapter, Volume};
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ impl PartialOrd for PostInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn check_feed(series_slug: &str, series_has_parts: bool) -> Result<Vec<PostInfo>, String> {
|
pub(crate) async fn check_feed(series_slug: &str, series_has_parts: bool) -> Result<Vec<PostInfo>, ()> {
|
||||||
let response = match HTTP_CLIENT
|
let response = match HTTP_CLIENT
|
||||||
.get(api_url!() + "/series/" + series_slug + "/volumes?format=json")
|
.get(api_url!() + "/series/" + series_slug + "/volumes?format=json")
|
||||||
.send()
|
.send()
|
||||||
|
@ -230,15 +230,27 @@ pub(crate) async fn check_feed(series_slug: &str, series_has_parts: bool) -> Res
|
||||||
Ok(data) => {
|
Ok(data) => {
|
||||||
match data.text().await {
|
match data.text().await {
|
||||||
Ok(data) => data,
|
Ok(data) => data,
|
||||||
Err(e) => return Err(format!("{}", e))
|
Err(e) => {
|
||||||
|
let err_msg = format!("{e}");
|
||||||
|
write_error(err_msg);
|
||||||
|
return Err(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(e) => return Err(format!("{}", e))
|
Err(e) => {
|
||||||
|
let err_msg = format!("{e}");
|
||||||
|
write_error(err_msg);
|
||||||
|
return Err(())
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut volume_brief_data: VolumesWrapper = match serde_json::from_str(&response) {
|
let mut volume_brief_data: VolumesWrapper = match serde_json::from_str(&response) {
|
||||||
Ok(data) => data,
|
Ok(data) => data,
|
||||||
Err(e) => return Err(format!("{}", e))
|
Err(e) => {
|
||||||
|
let err_msg = format!("{e}");
|
||||||
|
write_error(err_msg);
|
||||||
|
return Err(())
|
||||||
|
}
|
||||||
};
|
};
|
||||||
volume_brief_data.volumes.reverse(); // Makes breaking out of the volume loop easier
|
volume_brief_data.volumes.reverse(); // Makes breaking out of the volume loop easier
|
||||||
|
|
||||||
|
@ -330,7 +342,7 @@ pub(crate) async fn check_feed(series_slug: &str, series_has_parts: bool) -> Res
|
||||||
Ok(result_vec)
|
Ok(result_vec)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_latest_prepub(volume_slug: &str) -> Result<Option<LemmyPostInfo>, String> {
|
async fn get_latest_prepub(volume_slug: &str) -> Result<Option<LemmyPostInfo>, ()> {
|
||||||
let response = match HTTP_CLIENT
|
let response = match HTTP_CLIENT
|
||||||
.get(api_url!() + "/volumes/" + volume_slug + "/parts?format=json")
|
.get(api_url!() + "/volumes/" + volume_slug + "/parts?format=json")
|
||||||
.send()
|
.send()
|
||||||
|
@ -338,16 +350,28 @@ async fn get_latest_prepub(volume_slug: &str) -> Result<Option<LemmyPostInfo>, S
|
||||||
Ok(data) => {
|
Ok(data) => {
|
||||||
match data.text().await {
|
match data.text().await {
|
||||||
Ok(data) => data,
|
Ok(data) => data,
|
||||||
Err(e) => return Err(e.to_string())
|
Err(e) => {
|
||||||
|
let err_msg = format!("{e}");
|
||||||
|
write_error(err_msg);
|
||||||
|
return Err(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(e) => return Err(format!("{}", e))
|
Err(e) => {
|
||||||
|
let err_msg = format!("{e}");
|
||||||
|
write_error(err_msg);
|
||||||
|
return Err(())
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
let mut volume_prepub_parts_data: ChapterWrapper = match serde_json::from_str(&response) {
|
let mut volume_prepub_parts_data: ChapterWrapper = match serde_json::from_str(&response) {
|
||||||
Ok(data) => data,
|
Ok(data) => data,
|
||||||
Err(e) => return Err(format!("{}", e))
|
Err(e) => {
|
||||||
|
let err_msg = format!("{e}");
|
||||||
|
write_error(err_msg);
|
||||||
|
return Err(())
|
||||||
|
}
|
||||||
};
|
};
|
||||||
volume_prepub_parts_data.parts.reverse(); // Makes breaking out of the parts loop easier
|
volume_prepub_parts_data.parts.reverse(); // Makes breaking out of the parts loop easier
|
||||||
|
|
Loading…
Reference in a new issue