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MIMQYTTSA5DRMTQET5B7CL6CI6AC
O53GR2OQHGRKAVJT2RVPRHYFB54W5LM4DQYT7EYVGKU7HDK5CJJQC
M4FCDZ745GHHL3OLH64EVYOEOEGGGVIBCVFGX5JUJDJRE5OLCXLQC
76TBVFPIFU3LSMXY5NAHZBH6HRJLSLK43PGOPL6QQ2YYVBJ64QAQC
5FEMSWRS6SMVKBJAV4IYJLEJ2CML6QNZM75UGQFIIMAR5FBAACXAC
FFAFJQ5QVMHTLULZTGVM5PX7XQEZQUWLPH2GAN5BGVAYZOZZYG5QC
use std::collections::HashSet;
use std::fs::{self, DirBuilder, File};
use std::io::{self, BufReader, Read, Write};
use std::process::Command;
use structs::*;
use utils::*;
}
}
}
}
pub fn play_latest(state: &State, p_search: &str) {
let re_pod = Regex::new(&format!("(?i){}", &p_search)).expect("Failed to parse regex");
let mut path = get_xml_dir();
if let Err(err) = DirBuilder::new().recursive(true).create(&path) {
eprintln!(
"Couldn't create directory: {}\nReason: {}",
path.to_str().unwrap(),
err
);
return;
}
for subscription in &state.subscriptions {
if re_pod.is_match(&subscription.title) {
let mut filename = subscription.title.clone();
filename.push_str(".xml");
path.push(filename);
let mut file = File::open(&path).unwrap();
let mut content: Vec<u8> = Vec::new();
file.read_to_end(&mut content).unwrap();
let podcast = Podcast::from(Channel::read_from(content.as_slice()).unwrap());
let episodes = podcast.episodes();
let episode = episodes[0].clone();
filename = String::from(episode.title().unwrap());
filename.push_str(episode.extension().unwrap());
path = get_podcast_dir();
path.push(podcast.title());
path.push(filename);
if path.exists() {
launch_player(path.to_str().unwrap());
} else {
launch_player(episode.url().unwrap());
let episode = play_matches.value_of("EPISODE").unwrap();
play_episode(&state, podcast, episode);
match play_matches.value_of("EPISODE") {
Some(episode) => play_episode(&state, podcast, episode),
None => play_latest(&state, podcast),
}
use std::collections::BTreeSet;
use std::fs::{self, remove_dir_all, remove_file, DirBuilder, File};
use std::io::{self, BufReader, Read, Write};
use utils::*;
println!("Downloading: {}", path.to_str().unwrap());
let mut file = File::create(&path)?;
let mut resp = reqwest::get(url).unwrap();
let mut content: Vec<u8> = Vec::new();
resp.read_to_end(&mut content)?;
file.write_all(&content)?;
return Ok(());
if !path.exists() {
println!("Downloading: {}", path.to_str().unwrap());
let mut file = File::create(&path)?;
let mut resp = reqwest::get(url).unwrap();
let mut content: Vec<u8> = Vec::new();
resp.read_to_end(&mut content)?;
file.write_all(&content)?;
return Ok(());
} else {
println!("File already exists: {}", path.to_str().unwrap());
return Ok(());
}