From 68d185b7ef3a3a6695e0d54db46ebbdef8145b9f Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Fri, 22 Sep 2017 15:26:21 +0300 Subject: [PATCH] I hate daytimes with a passion. --- src/feedparser.rs | 21 ++++++++++++++++----- src/index_feed.rs | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/feedparser.rs b/src/feedparser.rs index 3c0a3be..7d64cd4 100644 --- a/src/feedparser.rs +++ b/src/feedparser.rs @@ -27,7 +27,6 @@ pub fn parse_podcast(chan: &Channel, source_id: i32) -> Result(item: &'a Item, parent_id: i32) -> Result> { let title = item.title(); @@ -47,11 +46,23 @@ pub fn parse_episode<'a>(item: &'a Item, parent_id: i32) -> Result { + // info!("{}", foo); + let date = DateTime::parse_from_rfc2822(foo); + match date { + Ok(bar) => bar.timestamp() as i32, + Err(baz) => { + error!("Error while trying to parse \"{}\" as date.", foo); + error!("{}", baz); + debug!("Falling back to default 0"); + 0 + } + } + } + _ => 0 + }; let length = item.enclosure().map(|x| x.length().parse().unwrap_or_default()); diff --git a/src/index_feed.rs b/src/index_feed.rs index c3149ff..69cd58d 100644 --- a/src/index_feed.rs +++ b/src/index_feed.rs @@ -12,7 +12,7 @@ pub fn foo() { let inpt = vec![ "https://request-for-explanation.github.io/podcast/rss.xml", "https://feeds.feedburner.com/InterceptedWithJeremyScahill", - "http://feeds.propublica.org/propublica/main", + "http://feeds.propublica.org/propublica/podcast", "http://feeds.feedburner.com/linuxunplugged", ];