diff options
| author | njaremko | 2017-07-17 21:53:57 -0400 |
|---|---|---|
| committer | njaremko | 2017-07-17 21:53:57 -0400 |
| commit | 599d3dcc21bd843ccbcd603c7f8b64789417845e (patch) | |
| tree | ff269bcabcb4e0a3b2653eb73bdcb767649b1243 | |
| parent | cd83d6ecaf7d9025c3db452268cf246ae4c4aaa0 (diff) | |
| download | podcast-599d3dcc21bd843ccbcd603c7f8b64789417845e.tar.bz2 | |
Sort imports
| -rw-r--r-- | src/actions.rs | 4 | ||||
| -rw-r--r-- | src/main.rs | 11 | ||||
| -rw-r--r-- | src/structs.rs | 8 | ||||
| -rw-r--r-- | src/utils.rs | 4 |
4 files changed, 12 insertions, 15 deletions
diff --git a/src/actions.rs b/src/actions.rs index b8074b1..4a6c122 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -1,6 +1,6 @@ use regex::Regex; +use std::process::Command; use structs::*; -use std::process::{Command, Stdio}; use utils::*; pub fn list_episodes(state: State, search: &str) { @@ -67,7 +67,7 @@ pub fn play_episode(state: State, p_search: &str, ep_num_string: &str) { let episode = episodes[episodes.len() - ep_num].clone(); let mut filename = String::from(episode.title().unwrap()); - filename.push_str(episode.download_extension().unwrap()); + filename.push_str(episode.extension().unwrap()); path.push(filename); match path.exists() { true => launch_mpv(path.to_str().unwrap()), diff --git a/src/main.rs b/src/main.rs index a001ad4..2f93899 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,22 +1,19 @@ -extern crate rss; +extern crate clap; extern crate regex; extern crate reqwest; +extern crate rss; extern crate serde; -extern crate serde_json; #[macro_use] extern crate serde_derive; -extern crate clap; -use std::fs::File; -use std::io::BufReader; -use rss::Channel; +extern crate serde_json; mod actions; mod structs; mod utils; use actions::*; -use structs::*; use clap::{Arg, App, SubCommand}; +use structs::*; fn main() { let mut state = State::new(); diff --git a/src/structs.rs b/src/structs.rs index 51f4fc1..c304832 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -1,10 +1,10 @@ use reqwest; use rss::{self, Channel, Item}; +use serde_json; +use std::collections::BTreeSet; use std::fs::{DirBuilder, File}; use std::io::{self, Read, Write}; use utils::*; -use serde_json; -use std::collections::BTreeSet; #[derive(Serialize, Deserialize, Clone)] pub struct Subscription { @@ -135,7 +135,7 @@ impl Episode { } } - pub fn download_extension(&self) -> Option<&str> { + pub fn extension(&self) -> Option<&str> { match self.0.enclosure() { Some(enclosure) => { match enclosure.mime_type() { @@ -158,7 +158,7 @@ impl Episode { if let Some(title) = self.title() { println!("Downloading: {}", title); let mut filename = String::from(title); - filename.push_str(self.download_extension().unwrap()); + filename.push_str(self.extension().unwrap()); path.push(filename); let mut file = File::create(&path)?; let mut resp = reqwest::get(url).unwrap(); diff --git a/src/utils.rs b/src/utils.rs index ab4876f..ffe691e 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,7 +1,7 @@ -use std::fs; -use std::path::PathBuf; use std::collections::BTreeSet; use std::env; +use std::fs; +use std::path::PathBuf; pub fn already_downloaded(dir: &str) -> BTreeSet<String> { |
