diff --git a/src/parse_feeds.rs b/src/feedparser.rs similarity index 100% rename from src/parse_feeds.rs rename to src/feedparser.rs diff --git a/src/index_feed.rs b/src/index_feed.rs index 019243f..f268669 100644 --- a/src/index_feed.rs +++ b/src/index_feed.rs @@ -30,9 +30,9 @@ pub fn foo() { fn insert_source(connection: &SqliteConnection, url: &str) -> Result<()> { let foo = NewSource::new_with_uri(url); - diesel::insert(&foo).into(schema::source::table).execute( - connection, - )?; + diesel::insert_or_replace(&foo) + .into(schema::source::table) + .execute(connection)?; Ok(()) } @@ -40,16 +40,17 @@ fn insert_source(connection: &SqliteConnection, url: &str) -> Result<()> { pub fn index_loop(db: SqliteConnection) -> Result<()> { // let db = ::establish_connection(); - use parse_feeds; + use feedparser; let f = dbqueries::get_sources(&db); for feed in f.unwrap().iter_mut() { - info!("{:?}", feed.id()); + // info!("{:?}", feed.id()); + // This method will defently get split and nuked // but for now its poc let chan = feed.get_podcast_chan(&db)?; - let pd = parse_feeds::parse_podcast(&chan, feed.id())?; + let pd = feedparser::parse_podcast(&chan, feed.id())?; // TODO: Separate the insert/update logic diesel::insert_or_replace(&pd) @@ -59,7 +60,7 @@ pub fn index_loop(db: SqliteConnection) -> Result<()> { // Holy shit this works! let episodes: Vec<_> = chan.items() .iter() - .map(|x| parse_feeds::parse_episode(x, feed.id()).unwrap()) + .map(|x| feedparser::parse_episode(x, feed.id()).unwrap()) .collect(); // lazy invoking the compiler to check for the Vec type :3 @@ -70,7 +71,7 @@ pub fn index_loop(db: SqliteConnection) -> Result<()> { .execute(&db)?; info!("{:#?}", pd); - info!("{:#?}", episodes); + // info!("{:#?}", episodes); // info!("{:?}", chan); } diff --git a/src/lib.rs b/src/lib.rs index 4811e4b..7ffbc57 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,7 +26,7 @@ extern crate rss; pub mod cli; pub mod schema; pub mod models; -pub mod parse_feeds; +pub mod feedparser; pub mod index_feed; pub mod dbqueries; diff --git a/src/models.rs b/src/models.rs index d04c1fb..32d950c 100644 --- a/src/models.rs +++ b/src/models.rs @@ -87,7 +87,7 @@ impl<'a> Source { self.update(con, etag, lst_mod)?; let chan = Channel::from_str(&buf)?; - // let foo = ::parse_feeds::parse_podcast(&chan, self.id())?; + // let foo = ::feedparser::parse_podcast(&chan, self.id())?; Ok(chan) } @@ -160,7 +160,7 @@ impl<'a> NewPodcast { pub fn from_url(uri: &'a str, parent: &Source) -> Result { let chan = Channel::from_url(uri)?; - let foo = ::parse_feeds::parse_podcast(&chan, parent.id())?; + let foo = ::feedparser::parse_podcast(&chan, parent.id())?; Ok(foo) } } \ No newline at end of file