diff options
author | metamuffin <metamuffin@disroot.org> | 2023-08-01 21:52:53 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-08-01 21:52:53 +0200 |
commit | 6eafafe5297c54aa5cb38790c45ba189b47d755e (patch) | |
tree | e79428752295c185aed6713f24b1202d2a0a35b3 | |
parent | ff9060ea0987e29e4d468ff7c9fed7cc7109bf2b (diff) | |
download | jellything-6eafafe5297c54aa5cb38790c45ba189b47d755e.tar jellything-6eafafe5297c54aa5cb38790c45ba189b47d755e.tar.bz2 jellything-6eafafe5297c54aa5cb38790c45ba189b47d755e.tar.zst |
remote downloa
-rw-r--r-- | common/src/config.rs (renamed from server/src/config.rs) | 7 | ||||
-rw-r--r-- | common/src/impl.rs | 5 | ||||
-rw-r--r-- | common/src/lib.rs | 1 | ||||
-rw-r--r-- | server/src/main.rs | 7 | ||||
-rw-r--r-- | server/src/routes/ui/account/session/mod.rs | 5 | ||||
-rw-r--r-- | server/src/routes/ui/account/session/token.rs | 5 | ||||
-rw-r--r-- | tools/src/bin/import.rs | 22 |
7 files changed, 43 insertions, 9 deletions
diff --git a/server/src/config.rs b/common/src/config.rs index 05c56bc..b978a1e 100644 --- a/server/src/config.rs +++ b/common/src/config.rs @@ -3,8 +3,9 @@ which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2023 metamuffin <metamuffin.org> */ + use serde::{Deserialize, Serialize}; -use std::{collections::HashMap, fs::File, path::PathBuf}; +use std::{collections::HashMap, path::PathBuf}; #[derive(Debug, Deserialize, Serialize, Default)] pub struct GlobalConfig { @@ -21,7 +22,3 @@ pub struct GlobalConfig { pub login_expire: i64, pub remote_credentials: HashMap<String, (String, String, bool)>, } - -pub fn load_global_config() -> GlobalConfig { - serde_json::from_reader(File::open("data/config.json").unwrap()).unwrap() -} diff --git a/common/src/impl.rs b/common/src/impl.rs index a7f8c6a..55364ab 100644 --- a/common/src/impl.rs +++ b/common/src/impl.rs @@ -1,3 +1,8 @@ +/* + 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) 2023 metamuffin <metamuffin.org> +*/ use crate::{SourceTrack, SourceTrackKind}; impl SourceTrackKind { diff --git a/common/src/lib.rs b/common/src/lib.rs index 323070b..3f91a6c 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -4,6 +4,7 @@ Copyright (C) 2023 metamuffin <metamuffin.org> */ pub mod r#impl; +pub mod config; use bincode::{Decode, Encode}; use serde::{Deserialize, Serialize}; diff --git a/server/src/main.rs b/server/src/main.rs index eba9532..341f72b 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -5,19 +5,20 @@ */ #![feature(lazy_cell)] -use config::{load_global_config, GlobalConfig}; +use std::fs::File; use database::Database; +use jellycommon::config::GlobalConfig; use jellyremuxer::RemuxerContext; use once_cell::sync::Lazy; use rocket::launch; use routes::build_rocket; -pub mod config; pub mod database; pub mod import; pub mod routes; -pub static CONF: Lazy<GlobalConfig> = Lazy::new(load_global_config); +pub static CONF: Lazy<GlobalConfig> = + Lazy::new(|| serde_json::from_reader(File::open("data/config.json").unwrap()).unwrap()); #[launch] fn rocket() -> _ { diff --git a/server/src/routes/ui/account/session/mod.rs b/server/src/routes/ui/account/session/mod.rs index 1546ee7..2a7908f 100644 --- a/server/src/routes/ui/account/session/mod.rs +++ b/server/src/routes/ui/account/session/mod.rs @@ -1,3 +1,8 @@ +/* + 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) 2023 metamuffin <metamuffin.org> +*/ use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; diff --git a/server/src/routes/ui/account/session/token.rs b/server/src/routes/ui/account/session/token.rs index f82b475..c8913d3 100644 --- a/server/src/routes/ui/account/session/token.rs +++ b/server/src/routes/ui/account/session/token.rs @@ -1,3 +1,8 @@ +/* + 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) 2023 metamuffin <metamuffin.org> +*/ use super::SessionData; use aes_gcm_siv::{ aead::{generic_array::GenericArray, Aead}, diff --git a/tools/src/bin/import.rs b/tools/src/bin/import.rs index 863e107..12cd161 100644 --- a/tools/src/bin/import.rs +++ b/tools/src/bin/import.rs @@ -5,7 +5,7 @@ Copyright (C) 2023 metamuffin <metamuffin.org> */ use anyhow::Context; use clap::{Parser, Subcommand}; -use jellycommon::{MediaInfo, Node, NodeKind, NodePrivate, NodePublic}; +use jellycommon::{config::GlobalConfig, MediaInfo, Node, NodeKind, NodePrivate, NodePublic}; use jellymatroska::read::EbmlReader; use jellyremuxer::import::import_read; use jellytools::tmdb::{tmdb_details, tmdb_image, tmdb_search}; @@ -32,6 +32,13 @@ enum Action { #[arg(short, long)] series: bool, }, + Remote { + config: PathBuf, + host: String, + #[arg(short, long)] + remote_id: Option<String>, + id: String, + }, Set { #[arg(short = 'I', long)] item: PathBuf, @@ -195,6 +202,19 @@ fn main() -> anyhow::Result<()> { Ok(()) } + Action::Remote { + host, + config, + remote_id, + id, + } => { + let config: GlobalConfig = + serde_json::from_reader(File::open(config).unwrap()).unwrap(); + + let (username, password, tls) = &config.remote_credentials[&id]; + + Ok(()) + } Action::Set { .. } => { // let mut iteminfo: ItemInfo = match File::open(item.clone()) { // Ok(f) => serde_json::from_reader(f)?, |