5JMYBRF3UYX4LFH7JK6S4BEDKRVKDFIL4YKTCWKMKP4TMNNGQFKQC
FFAFJQ5QVMHTLULZTGVM5PX7XQEZQUWLPH2GAN5BGVAYZOZZYG5QC
5GQNHICLSFAA7ZUFXUCNACCPAIIGK4DV2QPTONDNXLS4TJJTOFHAC
UIMZBURR7KOWSREO4GDH5C2LZDUTEZBKQNYWBYSFGUTRYJ4GKSNQC
476KTQSS5NXVCTVLVZQRGSYD5OAFBYG75VTSWBN26Q45RSMRT5YQC
ZYS43ILR4OXI7S2AYNGYSTK3IU2UVELIWVCCWDS7RVZQDSNJMDHQC
THSENT35O3PIXQ343QPPE3DJGR4YVULN6YPS5ETW5PXSVGZZQIZAC
Y6BVNXQ747WQKVB4JO3AHYOMBWNNJNPC6SG2UUCCZRIIXDMXJYDQC
76TBVFPIFU3LSMXY5NAHZBH6HRJLSLK43PGOPL6QQ2YYVBJ64QAQC
J64KBLKALQ3HQCY4HJU5H6WBXTATS7TKBYNNUUSNJE7JLWLYO66QC
BSPWOOHZMN3RAOHGJ2A3XKUOUCFFAOXS7YR67E3AARPPPIA5YPDAC
XIHPYOWDLQY2MVMVUQPH23O3TBALRG4G2CHSLWSCAYMY5NVJ32WQC
let download_limit = config.auto_download_limit as usize;
if download_limit > 0 {
let podcast = Podcast::from(channel);
let episodes = podcast.episodes();
&episodes[..download_limit].par_iter().for_each(|ref ep| {
if let Err(err) = ep.download(podcast.title()) {
eprintln!("Error downloading {}: {}", podcast.title(), err);
}
});
}
pub fn update_rss(state: &State) {
println!("Updating RSS feeds...");
state.subscriptions().par_iter().for_each(|ref sub| {
pub fn update_rss(state: &mut State) {
println!("Checking for new episodes...");
state.subs.par_iter_mut().for_each(|mut sub| {
let channel = Channel::read_from(BufReader::new(&content[..])).unwrap();
let mut filename = String::from(channel.title());
let podcast = Podcast::from(Channel::read_from(BufReader::new(&content[..])).unwrap());
path = get_podcast_dir();
path.push(".rss");
let mut filename = String::from(podcast.title());
if podcast.episodes().len() > sub.num_episodes {
&podcast.episodes()[..podcast.episodes().len() - sub.num_episodes]
.par_iter()
.for_each(|ref ep| if let Err(err) = ep.download(podcast.title()) {
eprintln!("Error downloading {}: {}", podcast.title(), err);
});
}
sub.num_episodes = podcast.episodes().len();
impl Config {
pub fn new() -> Config {
let mut path = get_podcast_dir();
let mut download_limit = 1;
let mut delete_limit = 0;
path.push(".config");
if path.exists() {
let mut s = String::new();
File::open(&path).unwrap().read_to_string(&mut s).unwrap();
let config = YamlLoader::load_from_str(&s).unwrap();
if config.len() > 0 {
let doc = &config[0];
if let Some(val) = doc["auto_download_limit"].as_i64() {
download_limit = val;
}
if let Some(val) = doc["auto_delete_limit"].as_i64() {
delete_limit = val;
}
}
}
Config {
auto_download_limit: download_limit,
auto_delete_limit: delete_limit,
}
}
}
pub fn already_downloaded(dir: &str) -> BTreeSet<String> {
let mut result = BTreeSet::new();
pub fn trim_extension(filename: &str) -> String {
let name = String::from(filename);
let index = name.rfind('.').unwrap();
String::from(&name[0..index])
}
pub fn find_extension(input: &str) -> Option<&str> {
let tmp = String::from(input);
if tmp.contains(".mp3") {
Some(".mp3")
} else if tmp.contains(".m4a") {
Some(".m4a")
} else if tmp.contains(".wav") {
Some(".wav")
} else if tmp.contains(".ogg") {
Some(".ogg")
} else {
None
}
}