added better arguments for anime and light novels

This commit is contained in:
Zastian Pretorius
2022-07-18 15:40:33 +01:00
9 changed files with 95 additions and 34 deletions

View File

@@ -1,9 +1,14 @@
use std::fs::File;
use std::io::Write;
use crate::{search_ln,chapter_selector,get_full_text,open_bat};
pub fn ln_read(){
let ln_url = search_ln();
pub fn ln_read(search: &str, chapter: u32){
//convert search in to Option<&str>
let ln_url = search_ln(&search);
let chapter = chapter as f64;
let mut selected_page = 1;
if chapter != 0.0{
selected_page = (chapter/48.0).ceil() as u32;
}
loop {
//make empty tuple called chapter_url with (String, u32, u32)
let chapter_url = chapter_selector(&ln_url, selected_page);

5
src/ln/mod.rs Normal file
View File

@@ -0,0 +1,5 @@
pub mod menu;
pub mod open_text;
pub mod scraper;
pub mod search;
pub mod ln;

View File

@@ -2,11 +2,16 @@ use crate::helpers::{fixing_text::remove_after_dash, take_input::string_input};
use colored::Colorize;
use regex::Regex;
pub fn search_ln() -> String {
pub fn search_ln(search: &str) -> String {
let mut _is_n = false;
print!("\x1B[2J\x1B[1;1H");
while !_is_n {
let search_path = string_input("What ln do you want to read? ");
//if search is None, take input from user
let search_path = if search == "" {
string_input("What ln do you want to read? ")
} else {
search.to_string()
};
let search_path = search_path.replace(' ', "+");
let url = "https://readlightnovels.net/?s=".to_string();
let url = format!("{}{}", url, search_path.trim()).trim().to_string();