diff options
| -rw-r--r-- | CHANGELOG | 3 | ||||
| -rw-r--r-- | Cargo.toml | 3 | ||||
| -rw-r--r-- | src/main.rs | 4 | ||||
| -rw-r--r-- | src/structs.rs | 13 |
4 files changed, 17 insertions, 6 deletions
@@ -1,3 +1,6 @@ +0.5.6 +- Escape filenames to prevent issues on some filesystems + 0.5.5 - Attempt at better handling file handles to fix windows bug regarding renaming .subscriptions.tmp @@ -1,6 +1,6 @@ [package] name = "podcast" -version = "0.5.5" +version = "0.5.6" authors = ["Nathan Jaremko <njaremko@gmail.com>"] description = "A command line podcast manager" license = "GPL-3.0" @@ -21,6 +21,7 @@ name = "podcast" chrono = { version = "0.4", features = ["serde"] } clap = "2.28" error-chain = "0.11" +lazy_static = "1.0" rayon = "0.9" regex = "0.2" reqwest = "0.8" diff --git a/src/main.rs b/src/main.rs index 4016199..96572cc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,8 @@ extern crate chrono; extern crate clap; #[macro_use] extern crate error_chain; +#[macro_use] +extern crate lazy_static; extern crate rayon; extern crate regex; extern crate reqwest; @@ -29,7 +31,7 @@ use utils::*; use clap::{App, Arg, SubCommand}; -const VERSION: &str = "0.5.5"; +const VERSION: &str = "0.5.6"; fn main() -> Result<()> { create_directories().chain_err(|| "unable to create directories")?; diff --git a/src/structs.rs b/src/structs.rs index 0caed73..97e6718 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -8,11 +8,16 @@ use std::io::{self, BufReader, Read, Write}; use chrono::prelude::*; use rayon::prelude::*; +use regex::Regex; use reqwest; use rss::{Channel, Item}; use serde_json; use yaml_rust::YamlLoader; +lazy_static! { + static ref FILENAME_ESCAPE: Regex = Regex::new(r#"[\\/:*?"<>|]"#).unwrap(); +} + pub struct Config { pub auto_download_limit: i64, } @@ -230,7 +235,7 @@ impl Podcast { Ok(downloaded) => { self.episodes().par_iter().for_each(|i| { if let Some(ep_title) = i.title() { - if !downloaded.contains(ep_title) { + if !downloaded.contains(&ep_title) { if let Err(err) = i.download(self.title()) { eprintln!("{}", err); } @@ -259,7 +264,7 @@ impl Podcast { episode_numbers.par_iter().for_each(|ep_num| { if let Some(ep_title) = episodes[episodes.len() - ep_num].title() { - if !downloaded.contains(ep_title) { + if !downloaded.contains(&ep_title) { if let Err(err) = episodes[episodes.len() - ep_num].download(self.title()) { println!("{}", err); } @@ -271,8 +276,8 @@ impl Podcast { } impl Episode { - pub fn title(&self) -> Option<&str> { - self.0.title() + pub fn title(&self) -> Option<String> { + Some(FILENAME_ESCAPE.replace_all(self.0.title()?, "_").to_string()) } pub fn url(&self) -> Option<&str> { |
