Skip to content

Commit

Permalink
Refactor podcast searching logic into it's own library: podcast_search
Browse files Browse the repository at this point in the history
  • Loading branch information
jaremn committed Jul 16, 2020
1 parent 9c33ee3 commit 30e4b1a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 210 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "podcast"
edition = "2018"
version = "0.15.0"
version = "0.16.0"
authors = ["Nathan Jaremko <[email protected]>"]
description = "A command line podcast manager"
license = "GPL-3.0"
Expand Down Expand Up @@ -36,4 +36,5 @@ serde_yaml = "0.8"
toml = "0.5"
percent-encoding = "2.1"
semver-parser = "0.9.0"
tokio = { version = "0.2", features = ["full"]}
tokio = { version = "0.2", features = ["full"]}
podcast_search = "0.1"
11 changes: 8 additions & 3 deletions src/arg_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use crate::actions::*;
use crate::download;
use crate::errors::*;
use crate::playback;
use crate::search;
use crate::structs::*;

pub async fn download(state: &mut State, matches: &ArgMatches<'_>) -> Result<()> {
Expand Down Expand Up @@ -112,7 +111,7 @@ pub fn complete(app: &mut App, matches: &ArgMatches) -> Result<()> {
pub async fn search(state: &mut State, config: Config, matches: &ArgMatches<'_>) -> Result<()> {
let matches = matches.subcommand_matches("search").unwrap();
let podcast = matches.value_of("PODCAST").unwrap();
let resp = search::search_for_podcast(podcast).await?;
let resp = podcast_search::search(podcast).await?;
if resp.results.is_empty() {
println!("No Results");
return Ok(());
Expand All @@ -122,7 +121,13 @@ pub async fn search(state: &mut State, config: Config, matches: &ArgMatches<'_>)
let stdout = io::stdout();
let mut lock = stdout.lock();
for (i, r) in resp.results.iter().enumerate() {
writeln!(&mut lock, "({}) {}", i, r.collection_name.clone().unwrap_or_else(|| "".to_string()))?;
writeln!(
&mut lock,
"({}) {} [{}]",
i,
r.collection_name.clone().unwrap_or_else(|| "".to_string()),
r.feed_url.clone().unwrap_or_else(|| "".to_string())
)?;
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ mod download;
mod migration_handler;
mod parser;
mod playback;
mod search;
mod structs;
mod utils;

Expand All @@ -39,7 +38,7 @@ use self::structs::*;
use errors::Result;
use std::io::Write;

const VERSION: &str = "0.15.0";
const VERSION: &str = "0.16.0";

#[tokio::main]
async fn main() -> Result<()> {
Expand Down
202 changes: 0 additions & 202 deletions src/search.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,4 @@ impl Episode {
_ => find_extension(self.url().unwrap()),
}
}
}
}

0 comments on commit 30e4b1a

Please sign in to comment.