work on init

This commit is contained in:
jb-alvarado 2024-06-13 20:58:39 +02:00
parent 80dbbd1627
commit 9714c5dcaf
4 changed files with 33 additions and 21 deletions

1
ffplayout-frontend Submodule

@ -0,0 +1 @@
Subproject commit e8532ba8d095ae83886df39ba53e9595b124f9c0

View File

@ -18,8 +18,12 @@ use crate::ARGS;
about = "REST API for ffplayout", about = "REST API for ffplayout",
long_about = None)] long_about = None)]
pub struct Args { pub struct Args {
#[clap(short, long, help = "ask for user credentials")] #[clap(
pub ask: bool, short,
long,
help = "Initialize defaults: global admin, paths, settings, etc."
)]
pub init: bool,
#[clap(long, env, help = "path to database file")] #[clap(long, env, help = "path to database file")]
pub db: Option<PathBuf>, pub db: Option<PathBuf>,
@ -93,22 +97,21 @@ pub struct Args {
pub async fn run_args(pool: &Pool<Sqlite>) -> Result<(), i32> { pub async fn run_args(pool: &Pool<Sqlite>) -> Result<(), i32> {
let mut args = ARGS.clone(); let mut args = ARGS.clone();
if args.ask { if args.init {
let mut user = String::new(); let mut user = String::new();
print!("Username: "); let mut mail = String::new();
let mut storage = String::new();
let mut playlist = String::new();
let mut hls = String::new();
print!("Global admin: ");
stdout().flush().unwrap(); stdout().flush().unwrap();
stdin() stdin()
.read_line(&mut user) .read_line(&mut user)
.expect("Did not enter a correct name?"); .expect("Did not enter a correct name?");
if let Some('\n') = user.chars().next_back() {
user.pop();
}
if let Some('\r') = user.chars().next_back() {
user.pop();
}
args.username = Some(user); args.username = Some(user.trim().to_string());
print!("Password: "); print!("Password: ");
stdout().flush().unwrap(); stdout().flush().unwrap();
@ -116,21 +119,29 @@ pub async fn run_args(pool: &Pool<Sqlite>) -> Result<(), i32> {
args.password = password.ok(); args.password = password.ok();
let mut mail = String::new();
print!("Mail: "); print!("Mail: ");
stdout().flush().unwrap(); stdout().flush().unwrap();
stdin() stdin()
.read_line(&mut mail) .read_line(&mut mail)
.expect("Did not enter a correct name?"); .expect("Did not enter a correct name?");
if let Some('\n') = mail.chars().next_back() {
mail.pop(); args.mail = Some(mail.trim().to_string());
}
if let Some('\r') = mail.chars().next_back() { print!("Storage path [/var/lib/ffplayout/tv-media]: ");
mail.pop(); stdout().flush().unwrap();
stdin()
.read_line(&mut storage)
.expect("Did not enter a correct path?");
if storage.trim().is_empty() {
args.storage_path = Some(PathBuf::from("/var/lib/ffplayout/tv-media"));
} else {
args.storage_path = Some(PathBuf::from(storage.trim()));
} }
args.mail = Some(mail); println!("{args:?}");
} }
if let Some(username) = args.username { if let Some(username) = args.username {

View File

@ -303,8 +303,6 @@ pub struct Processing {
pub help_text: String, pub help_text: String,
pub mode: ProcessMode, pub mode: ProcessMode,
pub audio_only: bool, pub audio_only: bool,
#[serde(default = "default_track_index")]
pub audio_track_index: i32,
pub copy_audio: bool, pub copy_audio: bool,
pub copy_video: bool, pub copy_video: bool,
pub width: i64, pub width: i64,
@ -317,6 +315,8 @@ pub struct Processing {
pub logo_opacity: f64, pub logo_opacity: f64,
pub logo_position: String, pub logo_position: String,
pub audio_tracks: i32, pub audio_tracks: i32,
#[serde(default = "default_track_index")]
pub audio_track_index: i32,
pub audio_channels: u8, pub audio_channels: u8,
pub volume: f64, pub volume: f64,
pub custom_filter: String, pub custom_filter: String,

View File

@ -80,7 +80,7 @@ CREATE TABLE
logging_help TEXT NOT NULL DEFAULT "If 'log_to_file' is true, log to file, when is false log to console. \n'local_time' to false will set log timestamps to UTC. Path to /var/log/ only if you run this program as daemon.\n'level' can be DEBUG, INFO, WARNING, ERROR.\n'ffmpeg_level/ingest_level' can be INFO, WARNING, ERROR.\n'detect_silence' logs an error message if the audio line is silent for 15 seconds during the validation process.\n'ignore_lines' makes logging to ignore strings that contains matched lines, in frontend is a semicolon separated list.", logging_help TEXT NOT NULL DEFAULT "If 'log_to_file' is true, log to file, when is false log to console. \n'local_time' to false will set log timestamps to UTC. Path to /var/log/ only if you run this program as daemon.\n'level' can be DEBUG, INFO, WARNING, ERROR.\n'ffmpeg_level/ingest_level' can be INFO, WARNING, ERROR.\n'detect_silence' logs an error message if the audio line is silent for 15 seconds during the validation process.\n'ignore_lines' makes logging to ignore strings that contains matched lines, in frontend is a semicolon separated list.",
logging_ffmpeg_level TEXT NOT NULL DEFAULT "ERROR", logging_ffmpeg_level TEXT NOT NULL DEFAULT "ERROR",
logging_ingest_level TEXT NOT NULL DEFAULT "ERROR", logging_ingest_level TEXT NOT NULL DEFAULT "ERROR",
logging_detect_silence INTEGER NOT NULL DEFAULT 1, logging_detect_silence INTEGER NOT NULL DEFAULT 0,
logging_ignore TEXT NOT NULL DEFAULT "P sub_mb_type 4 out of range at;error while decoding MB;negative number of zero coeffs at;out of range intra chroma pred mode;non-existing SPS 0 referenced in buffering period", logging_ignore TEXT NOT NULL DEFAULT "P sub_mb_type 4 out of range at;error while decoding MB;negative number of zero coeffs at;out of range intra chroma pred mode;non-existing SPS 0 referenced in buffering period",
processing_help TEXT NOT NULL DEFAULT "Default processing for all clips, to have them unique. Mode can be playlist or folder.\n'aspect' must be a float number.'logo' is only used if the path exist, path is relative to your storage folder.\n'logo_scale' scale the logo to target size, leave it blank when no scaling is needed, format is 'width:height', for example '100:-1' for proportional scaling. With 'logo_opacity' logo can become transparent.\nWith 'audio_tracks' it is possible to configure how many audio tracks should be processed.\n'audio_channels' can be use, if audio has more channels then only stereo.\nWith 'logo_position' in format 'x:y' you set the logo position.\nWith 'custom_filter' it is possible, to apply further filters. The filter outputs should end with [c_v_out] for video filter, and [c_a_out] for audio filter.", processing_help TEXT NOT NULL DEFAULT "Default processing for all clips, to have them unique. Mode can be playlist or folder.\n'aspect' must be a float number.'logo' is only used if the path exist, path is relative to your storage folder.\n'logo_scale' scale the logo to target size, leave it blank when no scaling is needed, format is 'width:height', for example '100:-1' for proportional scaling. With 'logo_opacity' logo can become transparent.\nWith 'audio_tracks' it is possible to configure how many audio tracks should be processed.\n'audio_channels' can be use, if audio has more channels then only stereo.\nWith 'logo_position' in format 'x:y' you set the logo position.\nWith 'custom_filter' it is possible, to apply further filters. The filter outputs should end with [c_v_out] for video filter, and [c_a_out] for audio filter.",
processing_mode TEXT NOT NULL DEFAULT "playlist", processing_mode TEXT NOT NULL DEFAULT "playlist",