mirror of
https://github.com/mrfluffy-dev/kami.git
synced 2026-01-17 12:50:32 +00:00
made image path dinamic
This commit is contained in:
@@ -168,11 +168,12 @@ pub fn anime_ui(
|
||||
fn run_app<B: Backend>(terminal: &mut Terminal<B>, mut app: App, conf: Config) -> io::Result<()> {
|
||||
let mut ep_select = false;
|
||||
fn change_image(conf: &Config, app: &App) {
|
||||
let config_path = dirs::config_dir().unwrap().join("kami");
|
||||
let image_path = config_path.join("tmp.jpg");
|
||||
let selected = app.messages.state.selected();
|
||||
let image_url = app.animes.2[selected.unwrap()].clone();
|
||||
get_image(&image_url);
|
||||
print_from_file("/home/mrfluffy/.config/kami/temp.png", &conf)
|
||||
.expect("Image printing failed.");
|
||||
get_image(&image_url, &image_path.to_str().unwrap());
|
||||
print_from_file(image_path, &conf).expect("Image printing failed.");
|
||||
}
|
||||
loop {
|
||||
terminal.draw(|f| ui(f, &mut app))?;
|
||||
|
||||
@@ -86,11 +86,11 @@ pub fn get_anime_link(url: &str, episode: u64) -> String {
|
||||
link.to_string()
|
||||
}
|
||||
|
||||
pub fn get_image(url: &str) {
|
||||
pub fn get_image(url: &str, path: &str) {
|
||||
let url = url;
|
||||
let mut response = isahc::get(url).unwrap();
|
||||
let mut buffer = Vec::new();
|
||||
response.copy_to(&mut buffer).unwrap();
|
||||
let mut file = File::create("/home/mrfluffy/.config/kami/temp.png").unwrap();
|
||||
let mut file = File::create(path).unwrap();
|
||||
file.write_all(&buffer).unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user