-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from B0SEmc/0.2.0
Add option to regarder and change la recherche
- Loading branch information
Showing
4 changed files
with
279 additions
and
56 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
[package] | ||
name = "ani-dl" | ||
version = "0.1.0" | ||
version = "0.2.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
serde = { version = "*", features = ["derive"] } | ||
serde_json = "*" | ||
inquire = "*" | ||
colored = "*" | ||
spinners = "*" | ||
titlecase = "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use colored::*; | ||
use serde::{Deserialize, Serialize}; | ||
use std::fmt::{Display, Formatter}; | ||
use titlecase::titlecase; | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
pub struct Animes { | ||
pub anime: Vec<Anime>, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone)] | ||
pub struct Anime { | ||
name: String, | ||
pub lang: String, | ||
season: i8, | ||
pub episodes: Vec<String>, | ||
} | ||
|
||
impl Display for Anime { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
write!(f, "saison {}", self.season.to_string().yellow(),) | ||
} | ||
} | ||
|
||
impl Animes { | ||
pub fn pretty_names(mut self) -> Self { | ||
for anime in &mut self.anime { | ||
anime.name = titlecase(&anime.name.replace('-', " ")); | ||
} | ||
self | ||
} | ||
pub fn get_name(&self) -> Vec<String> { | ||
let mut names = Vec::new(); | ||
for anime in &self.anime { | ||
if !names.contains(&anime.name) { | ||
names.push(anime.name.clone()); | ||
} | ||
} | ||
names | ||
} | ||
pub fn get_seasons_from_str(&self, name: &str) -> Vec<Anime> { | ||
let mut seasons = vec![]; | ||
for anime in &self.anime { | ||
if anime.name == name { | ||
seasons.push(anime.clone()); | ||
} | ||
} | ||
seasons | ||
} | ||
} |
Oops, something went wrong.