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/config.rs | 2 ++ common/src/lib.rs | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) (limited to 'common') diff --git a/common/src/config.rs b/common/src/config.rs index 4e90cf0..d9f2a8e 100644 --- a/common/src/config.rs +++ b/common/src/config.rs @@ -46,9 +46,11 @@ pub struct FederationAccount { #[serde(default = "return_true")] pub tls: bool, } + #[derive(Serialize, Deserialize, Debug)] pub struct ApiSecrets { pub tmdb: Option, + pub tvdb: Option, pub imdb: Option, pub omdb: Option, pub fanart_tv: Option, 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