Skip to content

Commit

Permalink
Merge pull request #1 from B0SEmc/0.2.0
Browse files Browse the repository at this point in the history
Add option to regarder and change la recherche
  • Loading branch information
B0SEmc authored Jun 18, 2024
2 parents 0a88323 + cbc8791 commit 48626bd
Show file tree
Hide file tree
Showing 4 changed files with 279 additions and 56 deletions.
182 changes: 180 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
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 = "*"
50 changes: 50 additions & 0 deletions src/anime.rs
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
}
}
Loading

0 comments on commit 48626bd

Please sign in to comment.