From 692d6d08c790c2b80e896978add1f6e0f0fc9451 Mon Sep 17 00:00:00 2001 From: Love Billenius Date: Wed, 8 Mar 2023 18:35:53 +0100 Subject: [PATCH] Fix error where file ending wasn't included --- src/main.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 220e461..a660089 100644 --- a/src/main.rs +++ b/src/main.rs @@ -178,7 +178,22 @@ async fn main() { ask_which_to_download(&mut readline, &search_result.as_ref().unwrap()); for to_download in download_selections.iter() { - let path = gm.config.data_dir.join(&to_download.name); + let file_ending = to_download + .name + .rfind(".") + .map(|dot_idx| { + if dot_idx < 6 { + &to_download.name[dot_idx..] + } else { + ".mkv" + } + }) + .unwrap_or_else(|| ".mkv"); + + let path = gm + .config + .data_dir + .join(format!("{}{}", &to_download.name, file_ending)); let path = Rc::new(path.to_string_lossy().to_string()); download_m3u8(to_download, Some(&path)).await; let data_entry = OfflineEntry::new((*to_download).clone(), path);