From 1d0ff1d0559aa9bcb03c02ce77230043f14787d1 Mon Sep 17 00:00:00 2001 From: bytedream Date: Mon, 8 Jan 2024 10:57:30 +0100 Subject: [PATCH] prepend `./` to the output path on linux if the input path is only a filename (#303) --- crunchy-cli-core/src/utils/download.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crunchy-cli-core/src/utils/download.rs b/crunchy-cli-core/src/utils/download.rs index 64a6d1a4..cb973cb9 100644 --- a/crunchy-cli-core/src/utils/download.rs +++ b/crunchy-cli-core/src/utils/download.rs @@ -7,6 +7,7 @@ use crunchyroll_rs::media::{Subtitle, VariantData, VariantSegment}; use crunchyroll_rs::Locale; use indicatif::{ProgressBar, ProgressDrawTarget, ProgressFinish, ProgressStyle}; use log::{debug, warn, LevelFilter}; +use nix::NixPath; use regex::Regex; use reqwest::Client; use std::borrow::Borrow; @@ -534,7 +535,14 @@ impl Downloader { if let Some(output_format) = self.output_format { command_args.extend(["-f".to_string(), output_format]); } - command_args.push(dst.to_str().unwrap().to_string()); + + // prepend './' to the path on linux since ffmpeg may interpret the path incorrectly if it's just the filename. + // see https://github.com/crunchy-labs/crunchy-cli/issues/303 for example + if !cfg!(windows) && dst.parent().map_or(true, |p| p.is_empty()) { + command_args.push(Path::new("./").join(dst).to_string_lossy().to_string()); + } else { + command_args.push(dst.to_string_lossy().to_string()) + } debug!("ffmpeg {}", command_args.join(" "));