Added a really crappy ui.
This commit is contained in:
parent
af60949e65
commit
f6d8f52a92
@ -26,7 +26,17 @@ pub fn get_podcasts(con: &SqliteConnection) -> QueryResult<Vec<Podcast>> {
|
||||
pub fn get_episodes(con: &SqliteConnection) -> QueryResult<Vec<Episode>> {
|
||||
use schema::episode::dsl::*;
|
||||
|
||||
let eps = episode.load::<Episode>(con);
|
||||
let eps = episode.order(epoch.desc()).load::<Episode>(con);
|
||||
eps
|
||||
}
|
||||
|
||||
pub fn get_episodes_with_limit(con: &SqliteConnection, limit: u32) -> QueryResult<Vec<Episode>> {
|
||||
use schema::episode::dsl::*;
|
||||
|
||||
let eps = episode
|
||||
.order(epoch.desc())
|
||||
.limit(limit as i64)
|
||||
.load::<Episode>(con);
|
||||
eps
|
||||
}
|
||||
|
||||
|
||||
@ -57,7 +57,7 @@ fn index_episode(con: &SqliteConnection, ep: &NewEpisode) -> Result<()> {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
fn insert_return_source(con: &SqliteConnection, url: &str) -> Result<Source> {
|
||||
pub fn insert_return_source(con: &SqliteConnection, url: &str) -> Result<Source> {
|
||||
let foo = NewSource::new_with_uri(url);
|
||||
index_source(con, &foo)?;
|
||||
|
||||
|
||||
45
src/main.rs
45
src/main.rs
@ -1,10 +1,9 @@
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate loggerv;
|
||||
|
||||
extern crate structopt;
|
||||
#[macro_use]
|
||||
extern crate structopt_derive;
|
||||
extern crate structopt;
|
||||
|
||||
#[macro_use]
|
||||
extern crate error_chain;
|
||||
@ -14,13 +13,24 @@ extern crate hammond;
|
||||
use structopt::StructOpt;
|
||||
use hammond::errors::*;
|
||||
use hammond::downloader;
|
||||
use hammond::index_feed;
|
||||
use hammond::dbqueries;
|
||||
|
||||
// Should probably had made an Enum instead.
|
||||
#[derive(StructOpt, Debug)]
|
||||
#[structopt(name = "example", about = "An example of StructOpt usage.")]
|
||||
struct Opt {
|
||||
/// Enable logging, use multiple `v`s to increase verbosity
|
||||
#[structopt(short = "v", long = "verbose")]
|
||||
verbosity: u64,
|
||||
|
||||
#[structopt(long = "update")] up: bool,
|
||||
|
||||
#[structopt(long = "latest")] latest: bool,
|
||||
|
||||
#[structopt(long = "download", default_value = "-1")] dl: i64,
|
||||
|
||||
#[structopt(short = "a", long = "add", default_value = "")] add: String,
|
||||
}
|
||||
|
||||
fn run() -> Result<()> {
|
||||
@ -28,14 +38,33 @@ fn run() -> Result<()> {
|
||||
|
||||
loggerv::init_with_verbosity(args.verbosity)?;
|
||||
|
||||
let foo = args;
|
||||
info!("{:?}", foo);
|
||||
|
||||
hammond::init()?;
|
||||
let db = hammond::establish_connection();
|
||||
downloader::latest_dl(&db, 2)?;
|
||||
|
||||
// Initial prototype for testings.
|
||||
// The plan is to write a Gtk+ gui later.
|
||||
if args.add != "".to_string() {
|
||||
let db = hammond::establish_connection();
|
||||
let _ = index_feed::insert_return_source(&db, &args.add);
|
||||
}
|
||||
|
||||
if args.up {
|
||||
let db = hammond::establish_connection();
|
||||
index_feed::index_loop(db)?;
|
||||
}
|
||||
|
||||
if args.dl >= 0 {
|
||||
let db = hammond::establish_connection();
|
||||
downloader::latest_dl(&db, args.dl as u32)?;
|
||||
}
|
||||
|
||||
if args.latest {
|
||||
let db = hammond::establish_connection();
|
||||
let foo = dbqueries::get_episodes_with_limit(&db, 10)?;
|
||||
// This ends up horribly but works for now.
|
||||
let _: Vec<_> = foo.iter().map(|x| println!("{:?}", x)).collect();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
quick_main!(run);
|
||||
quick_main!(run);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user