diff options
author | metamuffin <metamuffin@disroot.org> | 2023-12-21 23:57:42 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-12-21 23:57:42 +0100 |
commit | 3a29113e965a94bdef06655f1583cc6e86edd606 (patch) | |
tree | a0910fa9687a9935ba1ca85a9cb5def1a0bc9069 /common/src/lib.rs | |
parent | a8b2480e898e269e7e0d41dbd46d9a18c7d1e4ba (diff) | |
download | jellything-3a29113e965a94bdef06655f1583cc6e86edd606.tar jellything-3a29113e965a94bdef06655f1583cc6e86edd606.tar.bz2 jellything-3a29113e965a94bdef06655f1583cc6e86edd606.tar.zst |
rework import system pt. 1
Diffstat (limited to 'common/src/lib.rs')
-rw-r--r-- | common/src/lib.rs | 45 |
1 files changed, 29 insertions, 16 deletions
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)] |