mirror of
https://github.com/mrfluffy-dev/kami.git
synced 2026-01-17 04:50:32 +00:00
she be working again
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
use crate::{anime_link, anime_names};
|
||||
use crate::{
|
||||
get_an_progress, get_anime_id, get_user_anime_progress, update_anime_progress,
|
||||
write_an_progress,
|
||||
};
|
||||
use crate::{get_anime_link, get_animes};
|
||||
use crate::{open_cast, open_video};
|
||||
|
||||
use crossterm::{
|
||||
@@ -83,11 +83,13 @@ impl<T> StatefulList<T> {
|
||||
struct App {
|
||||
/// Current value of the input box
|
||||
input: String,
|
||||
animes: (Vec<String>, Vec<String>),
|
||||
/// Current input mode
|
||||
input_mode: InputMode,
|
||||
/// History of recorded messages
|
||||
messages: StatefulList<String>,
|
||||
title: String,
|
||||
link: String,
|
||||
ep: u64,
|
||||
progress: i32,
|
||||
anime_id: i32,
|
||||
@@ -100,9 +102,11 @@ impl<'a> App {
|
||||
fn default() -> App {
|
||||
App {
|
||||
input: String::new(),
|
||||
animes: (Vec::new(), Vec::new()),
|
||||
input_mode: InputMode::Normal,
|
||||
messages: StatefulList::with_items(Vec::new()),
|
||||
title: String::new(),
|
||||
link: String::new(),
|
||||
ep: 0,
|
||||
progress: 0,
|
||||
anime_id: 0,
|
||||
@@ -174,7 +178,8 @@ fn run_app<B: Backend>(terminal: &mut Terminal<B>, mut app: App) -> io::Result<(
|
||||
app.progress = 0;
|
||||
let selected = app.messages.state.selected();
|
||||
app.title = app.messages.items[selected.unwrap()].clone();
|
||||
let anime_info = get_anime_info(&app.title);
|
||||
app.link = app.animes.0[selected.unwrap()].clone();
|
||||
let anime_info = get_anime_info(&app.animes.0[selected.unwrap()]);
|
||||
app.anime_id = get_anime_id(anime_info.0);
|
||||
app.messages.items.clear();
|
||||
if app.token == "local" || app.anime_id == 0 {
|
||||
@@ -186,11 +191,14 @@ fn run_app<B: Backend>(terminal: &mut Terminal<B>, mut app: App) -> io::Result<(
|
||||
app.messages.state.select(Some(app.progress as usize));
|
||||
}
|
||||
if anime_info.1 == 1 {
|
||||
let link = anime_link(&app.title, 1, &app.provider);
|
||||
let link = get_anime_link(&app.link, 1);
|
||||
if !app.cast.0 {
|
||||
open_video((link.0, link.1));
|
||||
open_video((link, format!("{} Episode 1", &app.title)));
|
||||
} else {
|
||||
open_cast((link.0, link.1), &app.cast.1)
|
||||
open_cast(
|
||||
(link, format!("{} Episode 1", &app.title)),
|
||||
&app.cast.1,
|
||||
)
|
||||
}
|
||||
if app.token == "local" || app.anime_id == 0 {
|
||||
write_an_progress(&app.title, &1);
|
||||
@@ -213,11 +221,14 @@ fn run_app<B: Backend>(terminal: &mut Terminal<B>, mut app: App) -> io::Result<(
|
||||
.replace("Episode ", "")
|
||||
.parse::<u64>()
|
||||
.unwrap();
|
||||
let link = anime_link(&app.title, app.ep, &app.provider);
|
||||
let link = get_anime_link(&app.link, app.ep);
|
||||
if !app.cast.0 {
|
||||
open_video((link.0, link.1));
|
||||
open_video((link, format!("{} Episode {}", &app.title, app.ep)));
|
||||
} else {
|
||||
open_cast((link.0, link.1), &app.cast.1)
|
||||
open_cast(
|
||||
(link, format!("{} Episode {}", &app.title, app.ep)),
|
||||
&app.cast.1,
|
||||
)
|
||||
}
|
||||
if app.ep > app.progress as u64 {
|
||||
if app.token == "local" || app.anime_id == 0 {
|
||||
@@ -237,13 +248,12 @@ fn run_app<B: Backend>(terminal: &mut Terminal<B>, mut app: App) -> io::Result<(
|
||||
},
|
||||
InputMode::Editing => match key.code {
|
||||
KeyCode::Enter => {
|
||||
//push app.input into app.messages with '1
|
||||
let anime_list = anime_names(app.input.drain(..).collect());
|
||||
//push app.input into app.messages with '
|
||||
app.animes = get_animes(app.input.drain(..).collect());
|
||||
app.messages.items.clear();
|
||||
for anime in anime_list {
|
||||
for anime in &app.animes.1 {
|
||||
app.messages.push(anime.to_string());
|
||||
}
|
||||
|
||||
ep_select = false;
|
||||
app.input_mode = InputMode::Normal;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user