aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Jaremko2019-03-03 19:13:29 -0500
committerNathan Jaremko2019-03-03 19:13:29 -0500
commitc8b18e619d5d6aa61e85018603601c285448f809 (patch)
tree0a5d31173137d74692a3e2254bfaf065f06ad472
parentdf817a266c712c2122b86551b58babd047f4d622 (diff)
downloadpodcast-c8b18e619d5d6aa61e85018603601c285448f809.tar.bz2
Fix periods in title breaking file naming
-rw-r--r--src/actions.rs11
-rw-r--r--src/download.rs9
2 files changed, 13 insertions, 7 deletions
diff --git a/src/actions.rs b/src/actions.rs
index c943769..847d068 100644
--- a/src/actions.rs
+++ b/src/actions.rs
@@ -138,21 +138,22 @@ pub fn remove_podcast(state: &mut State, p_search: &str) -> Result<()> {
}
pub fn print_completion(app: &mut App, arg: &str) {
+ let command_name = "podcast";
match arg {
"zsh" => {
- app.gen_completions_to("podcast", Shell::Zsh, &mut io::stdout());
+ app.gen_completions_to(command_name, Shell::Zsh, &mut io::stdout());
}
"bash" => {
- app.gen_completions_to("podcast", Shell::Bash, &mut io::stdout());
+ app.gen_completions_to(command_name, Shell::Bash, &mut io::stdout());
}
"powershell" => {
- app.gen_completions_to("podcast", Shell::PowerShell, &mut io::stdout());
+ app.gen_completions_to(command_name, Shell::PowerShell, &mut io::stdout());
}
"fish" => {
- app.gen_completions_to("podcast", Shell::Fish, &mut io::stdout());
+ app.gen_completions_to(command_name, Shell::Fish, &mut io::stdout());
}
"elvish" => {
- app.gen_completions_to("podcast", Shell::Elvish, &mut io::stdout());
+ app.gen_completions_to(command_name, Shell::Elvish, &mut io::stdout());
}
other => {
println!("Completions are not available for {}", other);
diff --git a/src/download.rs b/src/download.rs
index be4598d..c58c9d8 100644
--- a/src/download.rs
+++ b/src/download.rs
@@ -63,9 +63,14 @@ pub fn download(podcast_name: &str, episode: &Episode) -> Result<(), Error> {
path.push(podcast_name);
create_dir_if_not_exist(&path)?;
- if let (Some(title), Some(url)) = (episode.title(), episode.url()) {
+ if let (Some(mut title), Some(url)) = (episode.title(), episode.url()) {
+ episode.extension().map(|ext| {
+ if !title.ends_with(".") {
+ title.push_str(".");
+ }
+ title.push_str(&ext);
+ });
path.push(title);
- episode.extension().map(|ext| path.set_extension(ext));
if !path.exists() {
println!("Downloading: {:?}", &path);
let resp = reqwest::get(url)?;