From a8fe841aaefe904121d936e608572a1422191167 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sun, 21 Jan 2024 19:29:17 +0100 Subject: trakt import --- common/src/lib.rs | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'common/src/lib.rs') 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, }, @@ -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() + } +} -- cgit v1.2.3-70-g09d2