diff --git a/README.md b/README.md index b263fbc..9092aa2 100644 --- a/README.md +++ b/README.md @@ -53,9 +53,9 @@ cp deploy.sh.example deploy.sh ### Environment Variables +- `INPUT_DIR`: Directory to monitor for new MP4 files (default: `/home/user/livestreams`) +- `OUTPUT_DIR`: Local output directory for processed files (default: `/media/archive/livestreams`) - `PC_SYNC_TARGET`: Remote sync destination (e.g., `user@server:/path/to/destination/`) -- `INPUT_DIR`: Directory to monitor for new files -- `OUTPUT_DIR`: Local output directory for processed files ### Service Configuration diff --git a/livestream-archiver.service.example b/livestream-archiver.service.example index 2f46cc2..dd8837a 100644 --- a/livestream-archiver.service.example +++ b/livestream-archiver.service.example @@ -8,7 +8,9 @@ User= Group= WorkingDirectory=/path/to/livestream-archiver ExecStart=/path/to/livestream-archiver/target/release/livestream_archiver -Environment=PC_SYNC_TARGET=user@server:/path/to/destination/ +Environment="PC_SYNC_TARGET=user@server:/path/to/destination/" +Environment="INPUT_DIR=/path/to/input/livestreams" +Environment="OUTPUT_DIR=/path/to/output/archive" Restart=always RestartSec=10 diff --git a/src/main.rs b/src/main.rs index 26c33f7..7f6c969 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ use std::path::PathBuf; +use std::env; use anyhow::Result; use notify::{Watcher, RecursiveMode, Event, EventKind}; use tokio::sync::mpsc; @@ -10,8 +11,18 @@ use services::livestream_archiver::LivestreamArchiver; #[tokio::main] async fn main() -> Result<()> { - let watch_path = PathBuf::from("/home/rockvilleav/Sync/Livestreams"); - let output_path = PathBuf::from("/media/archive/jellyfin/livestreams"); + let watch_path = PathBuf::from( + env::var("INPUT_DIR").unwrap_or_else(|_| { + eprintln!("INPUT_DIR not set, using default: /home/user/livestreams"); + "/home/user/livestreams".to_string() + }) + ); + let output_path = PathBuf::from( + env::var("OUTPUT_DIR").unwrap_or_else(|_| { + eprintln!("OUTPUT_DIR not set, using default: /media/archive/livestreams"); + "/media/archive/livestreams".to_string() + }) + ); // Ensure directories exist if !watch_path.exists() {