Compare commits
7 commits
Author | SHA1 | Date | |
---|---|---|---|
c76883d3ec | |||
3c4a68cb8f | |||
33ac3ae213 | |||
799bb6b8cd | |||
6b1ee28c06 | |||
16395dc570 | |||
c7cef6e7af |
5 changed files with 67 additions and 12 deletions
27
.github/workflows/build.yaml
vendored
Normal file
27
.github/workflows/build.yaml
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
# build.yaml
|
||||
# ---
|
||||
# Builds the rust code and verifies that it compiles
|
||||
|
||||
name: build
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.rs'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: install dependencies
|
||||
run: |
|
||||
apt update -y
|
||||
apt install -y curl gcc g++ make
|
||||
- uses: https://github.com/actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
- uses: https://github.com/actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
args: --verbose --all
|
|
@ -1,10 +1,3 @@
|
|||
# Bumblebee
|
||||
|
||||
Bumblebee is a simple wrapper around FFMPEG for transcoding media.
|
||||
|
||||
## (main) TODO
|
||||
main things that need to be done.
|
||||
|
||||
- [x] make initial behaviour work.
|
||||
- [ ] make archiving system work.
|
||||
- [ ] refactor code so it makes sense.
|
||||
Bumblebee is a simple wrapper around FFMPEG for transcoding media.
|
|
@ -1,6 +1,7 @@
|
|||
[files]
|
||||
input_path = "/data/input"
|
||||
output_path = "/data/output"
|
||||
keep_directory_structure = true # keep directory structure when outputting files
|
||||
include = [ 'mp4', 'avi', 'mkv' ] # file extensions to include
|
||||
|
||||
[files.cleanup]
|
||||
|
|
|
@ -32,6 +32,7 @@ pub struct ConfigFilesCleanup {
|
|||
pub struct ConfigFiles {
|
||||
pub input_path: String,
|
||||
pub output_path: String,
|
||||
pub keep_directory_structure: Option<bool>,
|
||||
pub include: Vec<String>,
|
||||
pub cleanup: Option<ConfigFilesCleanup>,
|
||||
}
|
||||
|
@ -51,6 +52,7 @@ impl Config {
|
|||
files: ConfigFiles {
|
||||
input_path: String::from("/data/input"),
|
||||
output_path: String::from("/data/output"),
|
||||
keep_directory_structure: None,
|
||||
include: Vec::new(),
|
||||
cleanup: None,
|
||||
},
|
||||
|
|
40
src/main.rs
40
src/main.rs
|
@ -23,7 +23,7 @@ fn main() {
|
|||
trace!("Config: {:#?}", &config);
|
||||
|
||||
debug!("commit: {}", env!("GIT_COMMIT_HASH"));
|
||||
debug!("version: {}", env!("GIT_TAG"));
|
||||
debug!("tag: {}", env!("GIT_TAG"));
|
||||
|
||||
let input_files = files::get_files(&config.files.input_path)
|
||||
.into_iter()
|
||||
|
@ -47,9 +47,21 @@ fn start_transcode_run(input_files: &Vec<PathBuf>, config: &Config) -> i32 {
|
|||
error!("Failed to process file {}: {}", job.input, remarks);
|
||||
};
|
||||
|
||||
let mut output_path = file.clone();
|
||||
let mut output_path = if let Some(keep_directory_structure) = config.files.keep_directory_structure {
|
||||
if keep_directory_structure {
|
||||
let mut output_path = PathBuf::from(&config.files.output_path);
|
||||
output_path.push(file.strip_prefix(&config.files.input_path).unwrap());
|
||||
output_path
|
||||
} else {
|
||||
PathBuf::from(&config.files.output_path)
|
||||
.join(file.file_name().unwrap())
|
||||
}
|
||||
} else {
|
||||
PathBuf::from(&config.files.output_path)
|
||||
.join(file.file_name().unwrap())
|
||||
};
|
||||
output_path.set_extension(&config.ffmpeg.output.format);
|
||||
let output_path = PathBuf::from(&config.files.output_path).join(output_path.file_name().unwrap()); // TODO: This is a bit of a mess.
|
||||
|
||||
|
||||
let job = TranscodeJob::new(
|
||||
file.to_str().unwrap(),
|
||||
|
@ -87,7 +99,27 @@ fn start_transcode_run(input_files: &Vec<PathBuf>, config: &Config) -> i32 {
|
|||
continue;
|
||||
}
|
||||
|
||||
// TODO: Cleanup
|
||||
if let Some(cleanup) = &config.files.cleanup {
|
||||
if !cleanup.enabled { () }
|
||||
match cleanup.original_cleanup_behavior {
|
||||
configuration::ConfigFilesCleanupOriginalBehavior::delete => {
|
||||
if let Err(e) = std::fs::remove_file(&job.input) {
|
||||
error!("Failed to delete original file {}: {}", job.input, e);
|
||||
}
|
||||
},
|
||||
configuration::ConfigFilesCleanupOriginalBehavior::archive => {
|
||||
let mut archive_path = PathBuf::from(&cleanup.archive.path);
|
||||
archive_path.push(job.input.strip_prefix(&config.files.input_path).unwrap());
|
||||
if let Err(e) = std::fs::create_dir_all(archive_path.parent().unwrap()) {
|
||||
error!("Failed to create archive directory {}: {}", archive_path.parent().unwrap().to_str().unwrap(), e);
|
||||
}
|
||||
if let Err(e) = std::fs::rename(&job.input, &archive_path) {
|
||||
error!("Failed to archive original file {}: {}", job.input, e);
|
||||
}
|
||||
},
|
||||
configuration::ConfigFilesCleanupOriginalBehavior::keep => (),
|
||||
}
|
||||
}
|
||||
|
||||
info!("Finished processing file {}.", job.input);
|
||||
success_count += 1;
|
||||
|
|
Loading…
Reference in a new issue