Final crate restructure I hope.
This commit is contained in:
parent
77797ee027
commit
93027e5530
@ -2,5 +2,5 @@
|
|||||||
members = [
|
members = [
|
||||||
"hammond-data",
|
"hammond-data",
|
||||||
"hammond-cli",
|
"hammond-cli",
|
||||||
"other"
|
"hammond-downloader"
|
||||||
]
|
]
|
||||||
|
|||||||
@ -10,7 +10,7 @@ structopt = "0.1.0"
|
|||||||
structopt-derive = "0.1.0"
|
structopt-derive = "0.1.0"
|
||||||
error-chain = "0.11.0"
|
error-chain = "0.11.0"
|
||||||
hammond-data = {path = "../hammond-data"}
|
hammond-data = {path = "../hammond-data"}
|
||||||
other = {path = "../other"}
|
hammond-downloader = {path = "../hammond-downloader"}
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
assert_cli = "0.5"
|
assert_cli = "0.5"
|
||||||
@ -1,21 +1,21 @@
|
|||||||
extern crate log;
|
extern crate log;
|
||||||
extern crate loggerv;
|
extern crate loggerv;
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
extern crate error_chain;
|
||||||
extern crate structopt;
|
extern crate structopt;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate structopt_derive;
|
extern crate structopt_derive;
|
||||||
#[macro_use]
|
|
||||||
extern crate error_chain;
|
|
||||||
|
|
||||||
extern crate other;
|
|
||||||
extern crate hammond_data;
|
extern crate hammond_data;
|
||||||
|
extern crate hammond_downloader;
|
||||||
|
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
use hammond_data::dbqueries;
|
use hammond_data::dbqueries;
|
||||||
use other::errors::*;
|
use hammond_data::errors::*;
|
||||||
use other::downloader;
|
use hammond_data::index_feed;
|
||||||
use other::index_feed;
|
use hammond_downloader::downloader;
|
||||||
|
|
||||||
// Should probably had made an Enum instead.
|
// Should probably had made an Enum instead.
|
||||||
#[derive(StructOpt, Debug)]
|
#[derive(StructOpt, Debug)]
|
||||||
#[structopt(name = "example", about = "An example of StructOpt usage.")]
|
#[structopt(name = "example", about = "An example of StructOpt usage.")]
|
||||||
@ -36,7 +36,7 @@ struct Opt {
|
|||||||
fn run() -> Result<()> {
|
fn run() -> Result<()> {
|
||||||
let args = Opt::from_args();
|
let args = Opt::from_args();
|
||||||
|
|
||||||
loggerv::init_with_verbosity(args.verbosity)?;
|
loggerv::init_with_verbosity(args.verbosity).unwrap();
|
||||||
|
|
||||||
hammond_data::init()?;
|
hammond_data::init()?;
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ fn run() -> Result<()> {
|
|||||||
|
|
||||||
if args.dl >= 0 {
|
if args.dl >= 0 {
|
||||||
let db = hammond_data::establish_connection();
|
let db = hammond_data::establish_connection();
|
||||||
downloader::latest_dl(&db, args.dl as u32)?;
|
downloader::latest_dl(&db, args.dl as u32).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
if args.latest {
|
if args.latest {
|
||||||
|
|||||||
@ -34,4 +34,4 @@ fn test_latest() {
|
|||||||
assert_cli::Assert::main_binary()
|
assert_cli::Assert::main_binary()
|
||||||
.with_args(&["--latest"])
|
.with_args(&["--latest"])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,13 +4,19 @@ version = "0.1.0"
|
|||||||
authors = ["Jordan Petridis <jordanpetridis@protonmail.com>"]
|
authors = ["Jordan Petridis <jordanpetridis@protonmail.com>"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
rfc822_sanitizer = "0.3.0"
|
||||||
rayon = "0.8.2"
|
rayon = "0.8.2"
|
||||||
|
hyper = "0.11.2"
|
||||||
|
reqwest = "0.7.3"
|
||||||
error-chain = "0.11.0"
|
error-chain = "0.11.0"
|
||||||
log = "0.3.8"
|
log = "0.3.8"
|
||||||
loggerv = "0.3.0"
|
loggerv = "0.3.0"
|
||||||
reqwest = "0.7.3"
|
|
||||||
diesel = { version = "0.16.0", features = ["sqlite", "deprecated-time", "chrono"] }
|
diesel = { version = "0.16.0", features = ["sqlite", "deprecated-time", "chrono"] }
|
||||||
diesel_codegen = { version = "0.16.0", features = ["sqlite"] }
|
diesel_codegen = { version = "0.16.0", features = ["sqlite"] }
|
||||||
xdg = "2.1.0"
|
xdg = "2.1.0"
|
||||||
lazy_static = "0.2.8"
|
lazy_static = "0.2.8"
|
||||||
|
rss = { version = "1.1.0", features = ["from_url"]}
|
||||||
|
dotenv = "*"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
tempdir = "0.3.5"
|
||||||
@ -1,7 +1,7 @@
|
|||||||
use rss::{Channel, Item};
|
use rss::{Channel, Item};
|
||||||
use rfc822_sanitizer::parse_from_rfc2822_with_fallback;
|
use rfc822_sanitizer::parse_from_rfc2822_with_fallback;
|
||||||
|
|
||||||
use hammond_data::models;
|
use models;
|
||||||
use errors::*;
|
use errors::*;
|
||||||
|
|
||||||
pub fn parse_podcast(chan: &Channel, source_id: i32) -> Result<models::NewPodcast> {
|
pub fn parse_podcast(chan: &Channel, source_id: i32) -> Result<models::NewPodcast> {
|
||||||
@ -7,10 +7,9 @@ use reqwest;
|
|||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use hammond_data::schema;
|
use schema;
|
||||||
use hammond_data::dbqueries;
|
use dbqueries;
|
||||||
use hammond_data::models::*;
|
use models::*;
|
||||||
|
|
||||||
use errors::*;
|
use errors::*;
|
||||||
use feedparser;
|
use feedparser;
|
||||||
|
|
||||||
@ -211,13 +210,11 @@ fn refresh_source(
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
||||||
extern crate hammond_data;
|
|
||||||
extern crate tempdir;
|
extern crate tempdir;
|
||||||
use diesel::prelude::*;
|
use diesel::prelude::*;
|
||||||
// use diesel::embed_migrations;
|
|
||||||
use rss;
|
use rss;
|
||||||
|
|
||||||
use std::io::{stdout, BufReader};
|
use std::io::BufReader;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
@ -239,7 +236,7 @@ mod tests {
|
|||||||
let db_path = tmp_dir.path().join("foo_tests.db");
|
let db_path = tmp_dir.path().join("foo_tests.db");
|
||||||
|
|
||||||
let db = SqliteConnection::establish(db_path.to_str().unwrap()).unwrap();
|
let db = SqliteConnection::establish(db_path.to_str().unwrap()).unwrap();
|
||||||
hammond_data::run_migration_on(&db).unwrap();
|
::run_migration_on(&db).unwrap();
|
||||||
|
|
||||||
// TempDB {
|
// TempDB {
|
||||||
// tmp_dir,
|
// tmp_dir,
|
||||||
@ -17,21 +17,35 @@ extern crate diesel_codegen;
|
|||||||
|
|
||||||
extern crate rayon;
|
extern crate rayon;
|
||||||
extern crate reqwest;
|
extern crate reqwest;
|
||||||
|
extern crate hyper;
|
||||||
extern crate xdg;
|
extern crate xdg;
|
||||||
|
extern crate rss;
|
||||||
|
extern crate rfc822_sanitizer;
|
||||||
|
|
||||||
pub mod dbqueries;
|
pub mod dbqueries;
|
||||||
pub mod models;
|
pub mod models;
|
||||||
pub mod schema;
|
pub mod schema;
|
||||||
|
|
||||||
|
pub mod index_feed;
|
||||||
|
pub mod feedparser;
|
||||||
|
|
||||||
pub mod errors {
|
pub mod errors {
|
||||||
|
|
||||||
use diesel::migrations::RunMigrationsError;
|
use diesel::migrations::RunMigrationsError;
|
||||||
use diesel::result;
|
use diesel::result;
|
||||||
|
use rss;
|
||||||
|
use hyper;
|
||||||
|
use reqwest;
|
||||||
|
use std::io;
|
||||||
|
|
||||||
error_chain! {
|
error_chain! {
|
||||||
foreign_links {
|
foreign_links {
|
||||||
MigrationError(RunMigrationsError);
|
MigrationError(RunMigrationsError);
|
||||||
DieselResultError(result::Error);
|
DieselResultError(result::Error);
|
||||||
|
RSSError(rss::Error);
|
||||||
|
HyperError(hyper::error::Error);
|
||||||
|
ReqError(reqwest::Error);
|
||||||
|
IoError(io::Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,21 +1,16 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "other"
|
name = "hammond-downloader"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Jordan Petridis <jordanpetridis@protonmail.com>"]
|
authors = ["Jordan Petridis <jordanpetridis@protonmail.com>"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
hammond-data = {path = "../hammond-data"}
|
hammond-data = {path = "../hammond-data"}
|
||||||
rayon = "0.8.2"
|
|
||||||
error-chain = "0.11.0"
|
error-chain = "0.11.0"
|
||||||
log = "0.3.8"
|
log = "0.3.8"
|
||||||
loggerv = "0.3.0"
|
loggerv = "0.3.0"
|
||||||
rfc822_sanitizer = "0.3.0"
|
|
||||||
reqwest = "0.7.3"
|
reqwest = "0.7.3"
|
||||||
hyper = "0.11.2"
|
hyper = "0.11.2"
|
||||||
diesel = { version = "0.16.0", features = ["sqlite"] }
|
diesel = { version = "0.16.0", features = ["sqlite"] }
|
||||||
diesel_codegen = { version = "0.16.0", features = ["sqlite"] }
|
diesel_codegen = { version = "0.16.0", features = ["sqlite"] }
|
||||||
rss = { version = "1.1.0", features = ["from_url"]}
|
rss = { version = "1.1.0", features = ["from_url"]}
|
||||||
dotenv = "*"
|
dotenv = "*"
|
||||||
|
|
||||||
[dev-dependencies]
|
|
||||||
tempdir = "0.3.5"
|
|
||||||
@ -8,6 +8,8 @@ use std::path::Path;
|
|||||||
|
|
||||||
use errors::*;
|
use errors::*;
|
||||||
use hammond_data::dbqueries;
|
use hammond_data::dbqueries;
|
||||||
|
use hammond_data::models::Episode;
|
||||||
|
use hammond_data::DL_DIR;
|
||||||
|
|
||||||
// Adapted from https://github.com/mattgathu/rget .
|
// Adapted from https://github.com/mattgathu/rget .
|
||||||
// I never wanted to write a custom downloader.
|
// I never wanted to write a custom downloader.
|
||||||
@ -54,9 +56,6 @@ pub fn download_to(target: &str, url: &str) -> Result<()> {
|
|||||||
|
|
||||||
// Initial messy prototype, queries load alot of not needed stuff.
|
// Initial messy prototype, queries load alot of not needed stuff.
|
||||||
pub fn latest_dl(connection: &SqliteConnection, limit: u32) -> Result<()> {
|
pub fn latest_dl(connection: &SqliteConnection, limit: u32) -> Result<()> {
|
||||||
use hammond_data::models::Episode;
|
|
||||||
use hammond_data::DL_DIR;
|
|
||||||
|
|
||||||
let pds = dbqueries::get_podcasts(connection)?;
|
let pds = dbqueries::get_podcasts(connection)?;
|
||||||
|
|
||||||
pds.iter()
|
pds.iter()
|
||||||
@ -1,6 +1,5 @@
|
|||||||
use reqwest;
|
use reqwest;
|
||||||
use rss;
|
use rss;
|
||||||
use hyper;
|
|
||||||
use diesel::result;
|
use diesel::result;
|
||||||
use hammond_data;
|
use hammond_data;
|
||||||
|
|
||||||
@ -10,10 +9,8 @@ error_chain! {
|
|||||||
foreign_links {
|
foreign_links {
|
||||||
ReqError(reqwest::Error);
|
ReqError(reqwest::Error);
|
||||||
IoError(io::Error);
|
IoError(io::Error);
|
||||||
Log(::log::SetLoggerError);
|
|
||||||
RSSError(rss::Error);
|
RSSError(rss::Error);
|
||||||
DieselResultError(result::Error);
|
DieselResultError(result::Error);
|
||||||
HyperError(hyper::error::Error);
|
|
||||||
HamDBError(hammond_data::errors::Error);
|
HamDBError(hammond_data::errors::Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7,12 +7,8 @@ extern crate hammond_data;
|
|||||||
extern crate hyper;
|
extern crate hyper;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
extern crate rayon;
|
|
||||||
extern crate reqwest;
|
extern crate reqwest;
|
||||||
extern crate rfc822_sanitizer;
|
|
||||||
extern crate rss;
|
extern crate rss;
|
||||||
|
|
||||||
pub mod feedparser;
|
|
||||||
pub mod downloader;
|
pub mod downloader;
|
||||||
pub mod index_feed;
|
|
||||||
pub mod errors;
|
pub mod errors;
|
||||||
Loading…
Reference in New Issue
Block a user