diff options
author | metamuffin <metamuffin@disroot.org> | 2024-01-21 19:29:17 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-01-21 19:29:17 +0100 |
commit | a8fe841aaefe904121d936e608572a1422191167 (patch) | |
tree | 0d4bb04670af5a6212938664ec70470841ac8399 /common/src/lib.rs | |
parent | 06d5c0d961c85abb3dd645b65b4447936fe7690f (diff) | |
download | jellything-a8fe841aaefe904121d936e608572a1422191167.tar jellything-a8fe841aaefe904121d936e608572a1422191167.tar.bz2 jellything-a8fe841aaefe904121d936e608572a1422191167.tar.zst |
trakt import
Diffstat (limited to 'common/src/lib.rs')
-rw-r--r-- | common/src/lib.rs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/common/src/lib.rs b/common/src/lib.rs index 5387679..57b210b 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -67,6 +67,10 @@ pub enum ImportSource { Tmdb { id: u64, }, + Trakt { + kind: TraktKind, + id: u64, + }, AutoChildren { path: Option<PathBuf>, }, @@ -163,6 +167,7 @@ pub enum Rating { YoutubeViews, YoutubeLikes, YoutubeFollowers, + Trakt, } #[derive(Debug, Clone, Deserialize, Serialize, Encode, Decode)] @@ -188,3 +193,50 @@ pub enum AssetRole { #[cfg_attr(feature = "rocket", field(value = "poster"))] Poster, #[cfg_attr(feature = "rocket", field(value = "backdrop"))] Backdrop, } + +#[derive(Debug, Serialize, Deserialize, Clone, Copy, Encode, Decode)] +#[serde(rename_all = "snake_case")] +pub enum TraktKind { + Movie, + Show, + Season, + Episode, + Person, + User, +} + +impl TraktKind { + pub fn singular(self) -> &'static str { + match self { + TraktKind::Movie => "movie", + TraktKind::Show => "show", + TraktKind::Season => "season", + TraktKind::Episode => "episode", + TraktKind::Person => "person", + TraktKind::User => "user", + } + } + pub fn plural(self) -> &'static str { + match self { + TraktKind::Movie => "movies", + TraktKind::Show => "shows", + TraktKind::Season => "seasons", + TraktKind::Episode => "episodes", + TraktKind::Person => "people", + TraktKind::User => "users", // //! not used in API + } + } +} +impl ToString for TraktKind { + fn to_string(&self) -> String { + match self { + TraktKind::Movie => "Movie", + TraktKind::Show => "Show", + TraktKind::Season => "Season", + TraktKind::Episode => "Episode", + TraktKind::Person => "Person", + TraktKind::User => "User", + } + .to_string() + } +} |