/* This file is part of jellything (https://codeberg.org/metamuffin/jellything) which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2025 metamuffin */ use crate::{jhls::EncodingProfile, user::PermissionSet}; use serde::{Deserialize, Serialize}; use std::{collections::HashMap, path::PathBuf}; #[rustfmt::skip] #[derive(Debug, Deserialize, Serialize, Default)] pub struct GlobalConfig { pub hostname: String, pub brand: String, pub slogan: String, #[serde(default = "return_true" )] pub tls: bool, #[serde(default = "default::asset_path")] pub asset_path: PathBuf, #[serde(default = "default::database_path")] pub database_path: PathBuf, #[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::secrets_path")] pub secrets_path: PathBuf, #[serde(default = "default::transcoding_profiles")] pub transcoding_profiles: Vec, #[serde(default = "default::max_in_memory_cache_size")] pub max_in_memory_cache_size: usize, #[serde(default)] pub use_in_memory_import_storage: bool, #[serde(default)] pub admin_username: Option, #[serde(default = "default::login_expire")] pub login_expire: i64, #[serde(default)] pub default_permission_set: PermissionSet, } #[derive(Serialize, Deserialize, Debug, Default)] pub struct SecretsConfig { #[serde(default)] pub federation: HashMap, #[serde(default)] pub api: ApiSecrets, #[serde(default)] pub cookie_key: Option, #[serde(default)] pub session_key: Option, #[serde(default)] pub admin_password: Option, } #[derive(Serialize, Deserialize, Debug)] pub struct FederationAccount { pub username: String, pub password: String, #[serde(default = "return_true")] pub tls: bool, } #[derive(Serialize, Deserialize, Debug, Default)] pub struct ApiSecrets { pub tmdb: Option, pub tvdb: Option, pub imdb: Option, pub omdb: Option, pub fanart_tv: Option, pub trakt: Option, } mod default { use crate::jhls::EncodingProfile; use std::path::PathBuf; pub fn login_expire() -> i64 { 60 * 60 * 24 } pub fn asset_path() -> PathBuf { "data/assets".into() } pub fn database_path() -> PathBuf { "data/database".into() } pub fn library_path() -> PathBuf { "data/library".into() } pub fn cache_path() -> PathBuf { "data/cache".into() } pub fn media_path() -> PathBuf { "data/media".into() } pub fn secrets_path() -> PathBuf { "data/secrets.yaml".into() } pub fn temp_path() -> PathBuf { "/tmp".into() } pub fn max_in_memory_cache_size() -> usize { 50_000_000 } pub fn transcoding_profiles() -> Vec { vec![ EncodingProfile::Video { codec: "libsvtav1".to_string(), preset: Some(8), bitrate: 2_000_000, width: Some(1920), }, EncodingProfile::Video { codec: "libsvtav1".to_string(), preset: Some(8), bitrate: 1_200_000, width: Some(1280), }, EncodingProfile::Video { codec: "libsvtav1".to_string(), preset: Some(8), bitrate: 300_000, width: Some(640), }, EncodingProfile::Audio { codec: "libopus".to_string(), bitrate: 128_000, sample_rate: None, channels: Some(2), }, EncodingProfile::Audio { codec: "libopus".to_string(), bitrate: 64_000, sample_rate: None, channels: Some(2), }, EncodingProfile::Subtitles { codec: "webvtt".to_string(), }, ] } } fn return_true() -> bool { true }