Added a simple program loop to repeatedly check for new video files
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
e3eb54720c
commit
e14795c493
@ -1,5 +1,6 @@
|
||||
use std::path::Path;
|
||||
use std::process;
|
||||
use std::{thread, time};
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::repository::Repository;
|
||||
@ -20,9 +21,14 @@ impl Transcoder {
|
||||
pub fn start(self) {
|
||||
println!("Starting transcoder...");
|
||||
|
||||
loop {
|
||||
// search for files in ingest
|
||||
let ingest_files = self.repository.search_ingest();
|
||||
|
||||
// check if we found any files to transcode
|
||||
if ingest_files.len() < 1 {
|
||||
println!("There were no files found in ingest to transcode; skipping run.");
|
||||
} else {
|
||||
for i in ingest_files {
|
||||
// copy the file to the archive
|
||||
self.repository.archive_file(&i);
|
||||
@ -35,6 +41,12 @@ impl Transcoder {
|
||||
}
|
||||
}
|
||||
|
||||
// put the loop to sleep for X minutes
|
||||
let sleep_minutes = time::Duration::from_secs((self.config.transcoder.interval * 60).into());
|
||||
thread::sleep(sleep_minutes);
|
||||
}
|
||||
}
|
||||
|
||||
fn transcode(&self, file: &str) {
|
||||
let ingest_file = Path::new(&self.repository.ingest_dir).join(file);
|
||||
let output_file = Path::new(&self.repository.output_dir).join(file);
|
||||
|
Loading…
Reference in New Issue
Block a user