diff options
Diffstat (limited to 'common/src')
-rw-r--r-- | common/src/config.rs | 4 | ||||
-rw-r--r-- | common/src/lib.rs | 45 |
2 files changed, 33 insertions, 16 deletions
diff --git a/common/src/config.rs b/common/src/config.rs index 3ccf0e8..200249c 100644 --- a/common/src/config.rs +++ b/common/src/config.rs @@ -19,6 +19,7 @@ pub struct GlobalConfig { #[serde(default = "default::library_path")] pub library_path: PathBuf, #[serde(default = "default::temp_path")] pub temp_path: PathBuf, #[serde(default = "default::cache_path")] pub cache_path: PathBuf, + #[serde(default = "default::media_path")] pub media_path: PathBuf, #[serde(default = "default::admin_username")] pub admin_username: String, #[serde(default = "default::transcoding_profiles")] pub transcoding_profiles: Vec<EncodingProfile>, #[serde(default = "default::max_in_memory_cache_size")] pub max_in_memory_cache_size: usize, @@ -53,6 +54,9 @@ mod default { pub fn cache_path() -> PathBuf { "data/cache".into() } + pub fn media_path() -> PathBuf { + "data/media".into() + } pub fn temp_path() -> PathBuf { "/tmp".into() } diff --git a/common/src/lib.rs b/common/src/lib.rs index aedcb07..e953d85 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -19,7 +19,7 @@ use rocket::{FromFormField, UriDisplayQuery}; use serde::{Deserialize, Serialize}; use std::{collections::BTreeMap, path::PathBuf}; -#[derive(Debug, Clone, Deserialize, Serialize)] +#[derive(Debug, Clone, Deserialize, Serialize, Default)] pub struct Node { pub public: NodePublic, pub private: NodePrivate, @@ -29,17 +29,16 @@ pub struct Node { #[derive(Debug, Clone, Deserialize, Serialize, Default)] pub struct NodePrivate { #[serde(default)] pub id: Option<String>, - #[serde(default)] pub import: Option<RemoteImportOptions>, #[serde(default)] pub poster: Option<AssetLocation>, #[serde(default)] pub backdrop: Option<AssetLocation>, - #[serde(default)] pub source: Option<MediaSource>, + #[serde(default)] pub source: Option<Vec<TrackSource>>, } #[rustfmt::skip] #[derive(Debug, Clone, Deserialize, Serialize, Default)] pub struct NodePublic { - pub kind: NodeKind, - pub title: String, + #[serde(default)] pub kind: Option<NodeKind>, + #[serde(default)] pub title: Option<String>, #[serde(default)] pub id: Option<String>, #[serde(default)] pub path: Vec<String>, #[serde(default)] pub children: Vec<String>, @@ -52,13 +51,25 @@ pub struct NodePublic { #[serde(default)] pub federated: Option<String>, } -#[rustfmt::skip] -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct RemoteImportOptions { - pub host: String, +#[derive(Debug, Clone, Deserialize, Serialize, Default)] +pub struct ImportOptions { pub id: String, - #[serde(default)] pub flatten: bool, - #[serde(default)] pub prefix: Option<String>, + pub sources: Vec<ImportSource>, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +#[serde(rename_all = "snake_case")] +pub enum ImportSource { + Override(Node), + Tmdb(u64), + AutoChildren, + Media { + location: AssetLocation, + // TODO ignore options + }, + Federated { + host: String, + }, } #[derive(Debug, Clone, Deserialize, Serialize, Hash, PartialEq, Eq)] @@ -68,6 +79,7 @@ pub enum AssetLocation { Library(PathBuf), Assets(PathBuf), Temp(PathBuf), + Media(PathBuf), } #[rustfmt::skip] @@ -87,9 +99,9 @@ pub enum NodeKind { #[derive(Debug, Clone, Deserialize, Serialize)] #[serde(rename_all = "snake_case")] -pub enum MediaSource { - Local { tracks: Vec<LocalTrack> }, - Remote { host: String, remote_id: String }, +pub enum TrackSource { + Local(LocalTrack), + Remote, } pub enum PublicMediaSource { @@ -128,18 +140,19 @@ pub struct SourceTrack { pub codec: String, pub language: String, pub default_duration: Option<u64>, + #[serde(default)] pub federated: Vec<String>, } #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord)] #[serde(rename_all = "snake_case")] pub enum Rating { + Imdb, + Tmdb, RottenTomatoes, Metacritic, - Imdb, YoutubeViews, YoutubeLikes, YoutubeFollowers, - Tmdb, } #[derive(Debug, Clone, Deserialize, Serialize)] |