mirror of
https://github.com/mrfluffy-dev/kami.git
synced 2026-01-17 12:50:32 +00:00
added resume functon for anime
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -315,7 +315,7 @@ checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kami"
|
name = "kami"
|
||||||
version = "0.5.0"
|
version = "0.5.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"colored",
|
"colored",
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use crate::{get_anime_id, get_token, get_user_anime_progress, update_anime_progr
|
|||||||
use crate::{int_input, string_input};
|
use crate::{int_input, string_input};
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
//use crate
|
//use crate
|
||||||
pub fn anime_stream(search: String, episode: u32) {
|
pub fn anime_stream(search: String, episode: u32, resume: bool) {
|
||||||
let token = get_token();
|
let token = get_token();
|
||||||
let query = if search != "" {
|
let query = if search != "" {
|
||||||
search
|
search
|
||||||
@@ -42,7 +42,7 @@ pub fn anime_stream(search: String, episode: u32) {
|
|||||||
let title = &anime_list[anime_num];
|
let title = &anime_list[anime_num];
|
||||||
let ep_range = anime_ep_range(title);
|
let ep_range = anime_ep_range(title);
|
||||||
// if there is only one episode, then don't ask user to choose episode
|
// if there is only one episode, then don't ask user to choose episode
|
||||||
let id = get_anime_id(&title.replace("-", " "));
|
let id = get_anime_id(&title);
|
||||||
if ep_range == 1 {
|
if ep_range == 1 {
|
||||||
let link = anime_link(title, 1);
|
let link = anime_link(title, 1);
|
||||||
open_video(link);
|
open_video(link);
|
||||||
@@ -57,7 +57,9 @@ pub fn anime_stream(search: String, episode: u32) {
|
|||||||
ep_num = episode as usize;
|
ep_num = episode as usize;
|
||||||
} else {
|
} else {
|
||||||
let current_progress = get_user_anime_progress(id, &token);
|
let current_progress = get_user_anime_progress(id, &token);
|
||||||
println!("you are currently on episode: {}", current_progress);
|
if resume && current_progress != 0 {
|
||||||
|
ep_num = (current_progress + 1) as usize;
|
||||||
|
} else {
|
||||||
println!("select episode 1-{}: ", ep_range);
|
println!("select episode 1-{}: ", ep_range);
|
||||||
while ep_num == usize::max_value() || ep_num > ep_range as usize {
|
while ep_num == usize::max_value() || ep_num > ep_range as usize {
|
||||||
ep_num = int_input("Enter episode number: ");
|
ep_num = int_input("Enter episode number: ");
|
||||||
@@ -66,6 +68,7 @@ pub fn anime_stream(search: String, episode: u32) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
loop {
|
loop {
|
||||||
let link = anime_link(title, ep_num as u64);
|
let link = anime_link(title, ep_num as u64);
|
||||||
open_video(link);
|
open_video(link);
|
||||||
@@ -91,7 +94,7 @@ pub fn anime_stream(search: String, episode: u32) {
|
|||||||
}
|
}
|
||||||
} else if input == "s" {
|
} else if input == "s" {
|
||||||
//remove all the arguments
|
//remove all the arguments
|
||||||
anime_stream("".to_string(), 0);
|
anime_stream("".to_string(), 0, false);
|
||||||
} else if input == "q" {
|
} else if input == "q" {
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
10
src/main.rs
10
src/main.rs
@@ -21,6 +21,7 @@ fn main() {
|
|||||||
let mut ln = false;
|
let mut ln = false;
|
||||||
let mut chapter: u32 = 0;
|
let mut chapter: u32 = 0;
|
||||||
let mut episode: u32 = 0;
|
let mut episode: u32 = 0;
|
||||||
|
let mut resume = false;
|
||||||
//let search = option string
|
//let search = option string
|
||||||
let mut search = String::new();
|
let mut search = String::new();
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
@@ -60,6 +61,10 @@ fn main() {
|
|||||||
episode = 0;
|
episode = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if arg == "--resume" || arg == "-r" {
|
||||||
|
resume = true;
|
||||||
|
}
|
||||||
|
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +89,7 @@ fn main() {
|
|||||||
if ln == true {
|
if ln == true {
|
||||||
ln_read(&search, chapter);
|
ln_read(&search, chapter);
|
||||||
} else if anime == true {
|
} else if anime == true {
|
||||||
anime_stream(search, episode);
|
anime_stream(search, episode, resume);
|
||||||
} else {
|
} else {
|
||||||
println!("Invalid argument");
|
println!("Invalid argument");
|
||||||
}
|
}
|
||||||
@@ -111,6 +116,9 @@ fn print_help() {
|
|||||||
println!("{}", "for exaple kami -c 200");
|
println!("{}", "for exaple kami -c 200");
|
||||||
//print blank line
|
//print blank line
|
||||||
println!("");
|
println!("");
|
||||||
|
println!("resume:\t\t{}", format_args!("{}", "-r --resume".red()));
|
||||||
|
println!("{}", "only works with anime".green());
|
||||||
|
println!("");
|
||||||
println!("light novel:\t{}", format_args!("{}", "-l --ln".red()));
|
println!("light novel:\t{}", format_args!("{}", "-l --ln".red()));
|
||||||
println!(
|
println!(
|
||||||
"{}",
|
"{}",
|
||||||
|
|||||||
Reference in New Issue
Block a user