From b127ee51925f59b306b032dbacc11464ed175a60 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sun, 21 Jan 2024 23:38:28 +0100 Subject: refactor tmdb api, cast&crew, node ext --- common/src/lib.rs | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) (limited to 'common/src/lib.rs') diff --git a/common/src/lib.rs b/common/src/lib.rs index 57b210b..f16338b 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -18,7 +18,7 @@ use bincode::{Decode, Encode}; #[cfg(feature = "rocket")] use rocket::{FromFormField, UriDisplayQuery}; use serde::{Deserialize, Serialize}; -use std::{collections::BTreeMap, path::PathBuf}; +use std::{collections::BTreeMap, fmt::Display, path::PathBuf}; #[derive(Debug, Clone, Deserialize, Serialize, Default, Encode, Decode)] pub struct Node { @@ -54,6 +54,57 @@ pub struct NodePublic { #[serde(default)] pub federated: Option, } +#[derive(Debug, Clone, Deserialize, Serialize, Default, Encode, Decode)] +pub struct ExtendedNode { + pub ids: ObjectIds, + pub people: BTreeMap>, +} + +#[derive(Debug, Clone, Deserialize, Serialize, Default, Encode, Decode)] +pub struct Appearance { + #[serde(default)] + pub jobs: Vec, + #[serde(default)] + pub characters: Vec, + pub person: Person, +} + +#[derive(Debug, Clone, Deserialize, Serialize, Default, Encode, Decode)] +pub struct Person { + pub name: String, + pub asset: Option, + pub ids: ObjectIds, +} + +#[derive(Debug, Clone, Deserialize, Serialize, Default, Encode, Decode)] +pub struct ObjectIds { + pub trakt: Option, + pub slug: Option, + pub imdb: Option, + pub tmdb: Option, + pub omdb: Option, + pub tvdb: Option, +} + +#[rustfmt::skip] +#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord, Encode, Decode)] +#[cfg_attr(feature = "rocket", derive(FromFormField, UriDisplayQuery))] +#[serde(rename_all = "snake_case")] +pub enum PeopleGroup { + #[cfg_attr(feature = "rocket", field(value = "cast"))] Cast, + #[cfg_attr(feature = "rocket", field(value = "writing"))] Writing, + #[cfg_attr(feature = "rocket", field(value = "directing"))] Directing, + #[cfg_attr(feature = "rocket", field(value = "art"))] Art, + #[cfg_attr(feature = "rocket", field(value = "sound"))] Sound, + #[cfg_attr(feature = "rocket", field(value = "camera"))] Camera, + #[cfg_attr(feature = "rocket", field(value = "lighting"))] Lighting, + #[cfg_attr(feature = "rocket", field(value = "crew"))] Crew, + #[cfg_attr(feature = "rocket", field(value = "editing"))] Editing, + #[cfg_attr(feature = "rocket", field(value = "production"))] Production, + #[cfg_attr(feature = "rocket", field(value = "vfx"))] Vfx, + #[cfg_attr(feature = "rocket", field(value = "costume"))] CostumeMakeup, +} + #[derive(Debug, Clone, Deserialize, Serialize, Default, Encode, Decode)] pub struct ImportOptions { pub id: String, @@ -240,3 +291,24 @@ impl ToString for TraktKind { .to_string() } } +impl Display for ObjectIds { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str("trakt")?; + if self.slug.is_some() { + f.write_str(",slug")?; + } + if self.tmdb.is_some() { + f.write_str(",tmdb")?; + } + if self.imdb.is_some() { + f.write_str(",imdb")?; + } + if self.tvdb.is_some() { + f.write_str(",tvdb")?; + } + if self.omdb.is_some() { + f.write_str(",omdb")?; + } + Ok(()) + } +} -- cgit v1.2.3-70-g09d2