did some formatting

This commit is contained in:
Zastian Pretorius
2022-07-26 13:14:38 +01:00
parent 585159455e
commit dcc57d22a9
3 changed files with 40 additions and 36 deletions

View File

@@ -1,14 +1,13 @@
use crate::{string_input,int_input};
use crate::{anime_names,anime_ep_range,anime_link};
use crate::open_video;
use crate::main;
use crate::open_video;
use crate::{anime_ep_range, anime_link, anime_names};
use crate::{int_input, string_input};
use colored::Colorize;
//use crate
pub fn anime_stream(search: String, episode: u32) {
let query = if search != "" {
search
}
else{
} else {
string_input("Search anime: ")
};
@@ -45,14 +44,12 @@ pub fn anime_stream(search: String, episode: u32) {
let link = anime_link(title, 1);
open_video(link);
main();
}
else {
} else {
let mut ep_num: usize = usize::MAX;
if episode > ep_range.into() {
println!("Invalid episode number");
main();
}
else if episode != 0{
} else if episode != 0 {
ep_num = episode as usize;
} else {
println!("select episode 1-{}: ", ep_range);
@@ -88,8 +85,7 @@ pub fn anime_stream(search: String, episode: u32) {
anime_stream("".to_string(), 0);
} else if input == "q" {
std::process::exit(0);
}
else{
} else {
println!("Invalid command");
}
}

View File

@@ -1,6 +1,6 @@
use crate::{chapter_selector, get_full_text, open_bat, search_ln};
use std::fs::File;
use std::io::Write;
use crate::{search_ln,chapter_selector,get_full_text,open_bat};
pub fn ln_read(search: &str, chapter: u32) {
//convert search in to Option<&str>
let ln_url = search_ln(&search);
@@ -19,7 +19,8 @@ pub fn ln_read(search: &str, chapter: u32){
let mut home = format!("{:?}", home_dir()).replace("\\\\", "/");
home.drain(0..6);
home.drain(home.len() - 2..home.len());
let mut file = File::create(format!("{}/AppData/Roaming/log_e",home)).expect("Unable to create file");
let mut file = File::create(format!("{}/AppData/Roaming/log_e", home))
.expect("Unable to create file");
file.write_all(full_text.as_bytes())
.expect("Unable to write to file");
file.sync_all().expect("Unable to sync file");

View File

@@ -21,9 +21,17 @@ pub fn chapter_selector(ln_url: &str, mut selected_page: u32) -> (String, u32) {
let mut count = 0;
ln_chapters.into_iter().for_each(|chaprer| {
if count % 2 == 0 {
println!("({})\t{}", count.to_string().blue(), format_args!("{}", chaprer.blue()));
println!(
"({})\t{}",
count.to_string().blue(),
format_args!("{}", chaprer.blue())
);
} else {
println!("({})\t{}", count.to_string().yellow(), format_args!("{}", chaprer.yellow()));
println!(
"({})\t{}",
count.to_string().yellow(),
format_args!("{}", chaprer.yellow())
);
}
count += 1;
});
@@ -43,8 +51,7 @@ pub fn chapter_selector(ln_url: &str, mut selected_page: u32) -> (String, u32) {
std::process::exit(0);
} else if chapter_number == "s" {
main();
}
else {
} else {
let chapter_number = chapter_number.trim().to_string();
let mut _chapter_number_int = 0;
if chapter_number.parse::<u32>().is_ok() {