EEJ6CBJRTXLPQP44I2RLWVLJBX565DXXAWU4JIWNA3MMNE7WB5LQC
let episodes = podcast.episodes();
&episodes[episodes.len() - range[1]..episodes.len() - range[0]]
.par_iter()
.for_each(|ref ep| if let Err(err) = ep.download(podcast.title()) {
println!("{}", err);
});
let episodes_to_download = parse_download_episodes(e_search);
podcast.download_specific(episodes_to_download);
println!("{}", err);
}
}
},
);
}
pub fn download_specific(&self, episode_numbers: Vec<usize>) {
let mut path = get_podcast_dir();
path.push(self.title());
let downloaded = already_downloaded(self.title());
let episodes = self.episodes();
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 let Err(err) = episodes[episodes.len() - ep_num].download(self.title()) {
pub fn parse_download_episodes(e_search: &str) -> Vec<usize> {
let input = String::from(e_search);
let mut ranges = Vec::<(usize, usize)>::new();
let mut elements = Vec::<usize>::new();
let comma_separated: Vec<&str> = input.split(',').collect();
for elem in comma_separated {
let temp = String::from(elem);
if temp.contains("-") {
let range: Vec<usize> = elem.split('-')
.map(|i| i.parse::<usize>().unwrap())
.collect();
ranges.push((range[0], range[1]));
} else {
elements.push(elem.parse::<usize>().unwrap());
}
}
for range in ranges {
// Add 1 to upper range to include given episode in the download
for num in range.0..range.1 + 1 {
elements.push(num);
}
}
elements.dedup();
elements
}