aboutsummaryrefslogtreecommitdiff
path: root/common/src
diff options
context:
space:
mode:
Diffstat (limited to 'common/src')
-rw-r--r--common/src/config.rs4
-rw-r--r--common/src/lib.rs49
2 files changed, 35 insertions, 18 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..9a3535a 100644
--- a/common/src/lib.rs
+++ b/common/src/lib.rs
@@ -19,27 +19,26 @@ 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,
+ #[serde(default)] pub public: NodePublic,
+ #[serde(default)] pub private: NodePrivate,
}
#[rustfmt::skip]
#[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)]