mirror of
https://github.com/mrfluffy-dev/kami.git
synced 2026-01-17 04:50:32 +00:00
added new providers
This commit is contained in:
@@ -92,6 +92,7 @@ struct App {
|
|||||||
progress: i32,
|
progress: i32,
|
||||||
anime_id: i32,
|
anime_id: i32,
|
||||||
token: String,
|
token: String,
|
||||||
|
provider: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> App {
|
impl<'a> App {
|
||||||
@@ -105,11 +106,12 @@ impl<'a> App {
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
anime_id: 0,
|
anime_id: 0,
|
||||||
token: String::new(),
|
token: String::new(),
|
||||||
|
provider: String::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn anime_ui(token: String) -> Result<(), Box<dyn Error>> {
|
pub fn anime_ui(token: String, provider: String) -> Result<(), Box<dyn Error>> {
|
||||||
// setup terminal
|
// setup terminal
|
||||||
enable_raw_mode()?;
|
enable_raw_mode()?;
|
||||||
let mut stdout = io::stdout();
|
let mut stdout = io::stdout();
|
||||||
@@ -120,6 +122,7 @@ pub fn anime_ui(token: String) -> Result<(), Box<dyn Error>> {
|
|||||||
// create app and run it
|
// create app and run it
|
||||||
let mut app = App::default();
|
let mut app = App::default();
|
||||||
app.token = token;
|
app.token = token;
|
||||||
|
app.provider = provider;
|
||||||
let res = run_app(&mut terminal, app);
|
let res = run_app(&mut terminal, app);
|
||||||
|
|
||||||
// restore terminal
|
// restore terminal
|
||||||
@@ -176,7 +179,7 @@ fn run_app<B: Backend>(terminal: &mut Terminal<B>, mut app: App) -> io::Result<(
|
|||||||
app.messages.state.select(Some(app.progress as usize));
|
app.messages.state.select(Some(app.progress as usize));
|
||||||
}
|
}
|
||||||
if anime_info.1 == 1 {
|
if anime_info.1 == 1 {
|
||||||
let link = anime_link(&app.title, 1);
|
let link = anime_link(&app.title, 1, &app.provider);
|
||||||
open_video((link.0, link.1));
|
open_video((link.0, link.1));
|
||||||
if app.token == "local" || app.anime_id == 0 {
|
if app.token == "local" || app.anime_id == 0 {
|
||||||
write_an_progress(&app.title, &1);
|
write_an_progress(&app.title, &1);
|
||||||
@@ -199,7 +202,7 @@ fn run_app<B: Backend>(terminal: &mut Terminal<B>, mut app: App) -> io::Result<(
|
|||||||
.replace("Episode ", "")
|
.replace("Episode ", "")
|
||||||
.parse::<u64>()
|
.parse::<u64>()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let link = anime_link(&app.title, app.ep);
|
let link = anime_link(&app.title, app.ep, &app.provider);
|
||||||
open_video((link.0, link.1));
|
open_video((link.0, link.1));
|
||||||
if app.ep > app.progress as u64 {
|
if app.ep > app.progress as u64 {
|
||||||
if app.token == "local" || app.anime_id == 0 {
|
if app.token == "local" || app.anime_id == 0 {
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ pub fn get_anime_info(title: &str) -> (i32, u16) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn anime_link(title: &str, ep: u64) -> (String, String) {
|
pub fn anime_link(title: &str, ep: u64, provider: &str) -> (String, String) {
|
||||||
let url = format!("https://animixplay.to/v1/{}", title);
|
let url = format!("https://animixplay.to/v1/{}", title);
|
||||||
let html = get_anime_html(&url);
|
let html = get_anime_html(&url);
|
||||||
let re = Regex::new(r#"(?m)\?id=([^&]+)"#).unwrap();
|
let re = Regex::new(r#"(?m)\?id=([^&]+)"#).unwrap();
|
||||||
@@ -86,6 +86,7 @@ pub fn anime_link(title: &str, ep: u64) -> (String, String) {
|
|||||||
None => "".to_string(),
|
None => "".to_string(),
|
||||||
};
|
};
|
||||||
if id1 != "" {
|
if id1 != "" {
|
||||||
|
if provider == "vrv" {
|
||||||
let title = format!("{} Episode {}", title.replace('-', " "), ep);
|
let title = format!("{} Episode {}", title.replace('-', " "), ep);
|
||||||
let encoded_id1 = encode(&id1);
|
let encoded_id1 = encode(&id1);
|
||||||
let encoded_id2 = encode(&encoded_id1);
|
let encoded_id2 = encode(&encoded_id1);
|
||||||
@@ -107,6 +108,20 @@ pub fn anime_link(title: &str, ep: u64) -> (String, String) {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.to_string();
|
.to_string();
|
||||||
return (result, title);
|
return (result, title);
|
||||||
|
} else if provider == "gogo" {
|
||||||
|
let title = format!("{} Episode {}", title.replace('-', " "), ep);
|
||||||
|
let encoded_id1 = encode(&id1);
|
||||||
|
let anime_id = encode(format!("{}LTXs3GrU8we9O{}", id1, encoded_id1));
|
||||||
|
let html = format!("https://animixplay.to/api/live{}", anime_id);
|
||||||
|
let url = get_ep_location(&html);
|
||||||
|
let url = url.split('#').nth(1).unwrap();
|
||||||
|
let url = std::str::from_utf8(&decode(url).unwrap())
|
||||||
|
.unwrap()
|
||||||
|
.to_string();
|
||||||
|
return (url, title);
|
||||||
|
} else {
|
||||||
|
panic!("Invalid provider");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let re = Regex::new(r#"(?m)r\.html#(.*)""#).unwrap();
|
let re = Regex::new(r#"(?m)r\.html#(.*)""#).unwrap();
|
||||||
let id2 = re
|
let id2 = re
|
||||||
|
|||||||
35
src/main.rs
35
src/main.rs
@@ -21,6 +21,7 @@ fn main() {
|
|||||||
let mut chapter: u32 = 0;
|
let mut chapter: u32 = 0;
|
||||||
//let search = option string
|
//let search = option string
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
|
let mut provider: String = "gogo".to_string();
|
||||||
for arg in std::env::args() {
|
for arg in std::env::args() {
|
||||||
if arg == "--help" || arg == "-h" {
|
if arg == "--help" || arg == "-h" {
|
||||||
help = true;
|
help = true;
|
||||||
@@ -28,6 +29,23 @@ fn main() {
|
|||||||
if arg == "--anime" || arg == "-a" {
|
if arg == "--anime" || arg == "-a" {
|
||||||
anime = true;
|
anime = true;
|
||||||
}
|
}
|
||||||
|
if arg == "--provider" || arg == "-r" {
|
||||||
|
if let Some(arg) = std::env::args().nth(count + 1) {
|
||||||
|
//get the next argument and see if it is = to gogo of vrv
|
||||||
|
if arg == "vrv" {
|
||||||
|
provider = "vrv".to_string();
|
||||||
|
count += 1;
|
||||||
|
} else if arg == "gogo" {
|
||||||
|
provider = "gogo".to_string();
|
||||||
|
count += 1;
|
||||||
|
} else {
|
||||||
|
provider = "gogo".to_string();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
provider = "vrv".to_string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if arg == "--ln" || arg == "-l" {
|
if arg == "--ln" || arg == "-l" {
|
||||||
ln = true;
|
ln = true;
|
||||||
}
|
}
|
||||||
@@ -67,7 +85,7 @@ fn main() {
|
|||||||
//anime_stream(search, episode, resume);
|
//anime_stream(search, episode, resume);
|
||||||
|
|
||||||
let token = get_token();
|
let token = get_token();
|
||||||
_ = anime_ui(token);
|
_ = anime_ui(token, provider);
|
||||||
} else {
|
} else {
|
||||||
println!("Invalid argument");
|
println!("Invalid argument");
|
||||||
}
|
}
|
||||||
@@ -88,6 +106,21 @@ fn print_help() {
|
|||||||
println!("{}", "for exaple kami -c 200");
|
println!("{}", "for exaple kami -c 200");
|
||||||
//print blank line
|
//print blank line
|
||||||
println!("");
|
println!("");
|
||||||
|
println!("provider:\t{}", format_args!("{}", "-r --provider".red()));
|
||||||
|
println!(
|
||||||
|
"{}",
|
||||||
|
"after this^^^ argument you can enter a provider".green()
|
||||||
|
);
|
||||||
|
println!(
|
||||||
|
"if no provider is entered it will default to {}",
|
||||||
|
"vrv".green()
|
||||||
|
);
|
||||||
|
println!(
|
||||||
|
"if the -r argument is not used it will default to {}",
|
||||||
|
"gogo".green()
|
||||||
|
);
|
||||||
|
println!("the providers are {} or {}", "gogo".green(), "vrv".green());
|
||||||
|
println!("");
|
||||||
println!("help:\t\t{}", format_args!("{}", "-h --help".red()));
|
println!("help:\t\t{}", format_args!("{}", "-h --help".red()));
|
||||||
//kill the program
|
//kill the program
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
|
|||||||
Reference in New Issue
Block a user