diff options
author | metamuffin <metamuffin@disroot.org> | 2024-01-21 23:38:28 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-01-21 23:38:28 +0100 |
commit | b127ee51925f59b306b032dbacc11464ed175a60 (patch) | |
tree | b7097c20a560019f90394de9e21da4c498aadabb /common/src | |
parent | a8fe841aaefe904121d936e608572a1422191167 (diff) | |
download | jellything-b127ee51925f59b306b032dbacc11464ed175a60.tar jellything-b127ee51925f59b306b032dbacc11464ed175a60.tar.bz2 jellything-b127ee51925f59b306b032dbacc11464ed175a60.tar.zst |
refactor tmdb api, cast&crew, node ext
Diffstat (limited to 'common/src')
-rw-r--r-- | common/src/lib.rs | 74 |
1 files changed, 73 insertions, 1 deletions
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 { @@ -55,6 +55,57 @@ pub struct NodePublic { } #[derive(Debug, Clone, Deserialize, Serialize, Default, Encode, Decode)] +pub struct ExtendedNode { + pub ids: ObjectIds, + pub people: BTreeMap<PeopleGroup, Vec<Appearance>>, +} + +#[derive(Debug, Clone, Deserialize, Serialize, Default, Encode, Decode)] +pub struct Appearance { + #[serde(default)] + pub jobs: Vec<String>, + #[serde(default)] + pub characters: Vec<String>, + pub person: Person, +} + +#[derive(Debug, Clone, Deserialize, Serialize, Default, Encode, Decode)] +pub struct Person { + pub name: String, + pub asset: Option<AssetLocation>, + pub ids: ObjectIds, +} + +#[derive(Debug, Clone, Deserialize, Serialize, Default, Encode, Decode)] +pub struct ObjectIds { + pub trakt: Option<u64>, + pub slug: Option<String>, + pub imdb: Option<String>, + pub tmdb: Option<u64>, + pub omdb: Option<u64>, + pub tvdb: Option<u64>, +} + +#[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, pub sources: Vec<ImportSource>, @@ -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(()) + } +} |