diff --git a/config.yaml b/config.yaml index cf060cf..e11ac96 100644 --- a/config.yaml +++ b/config.yaml @@ -4,12 +4,11 @@ theme: light # Options: daily, yesterday, weekly or all edition: weekly feeds: + - https://github.com/clockworkpi/launcher/releases.atom - https://programadorwebvalencia.com/feed/index.xml - http://planet.es.python.org/rss.xml - https://diarioestoico.com/feed/ - https://republicaweb.es/feed/podcast - -old: - https://static.fsf.org/fsforg/rss/news.xml - https://hakibenita.com/feeds/all.atom.xml - https://www.blogger.com/feeds/5402814408460261521/posts/default @@ -20,7 +19,6 @@ old: - https://twobithistory.org/feed.xml - https://nosinmiscookies.com/feed/ - http://planet.es.python.org/rss.xml - - https://github.com/clockworkpi/launcher/releases.atom - https://programadorwebvalencia.com/feed/index.xml - https://ondahostil.wordpress.com/feed/ - http://neofronteras.com/?feed=rss2 @@ -86,4 +84,4 @@ old: - http://au-agenda.com/feed/ - https://lisp-journey.gitlab.io/index.xml - https://slimbook.es/soporte?format=feed&type=rss - - https://jrsinclair.com/index.rss + - https://jrsinclair.com/index.rss \ No newline at end of file diff --git a/src/rsspaper/feeds.clj b/src/rsspaper/feeds.clj index 5246257..b43fbb8 100644 --- a/src/rsspaper/feeds.clj +++ b/src/rsspaper/feeds.clj @@ -20,8 +20,8 @@ (let [daily (c/to-long (t/minus (t/now) (t/days 1))) weekly (c/to-long (t/minus (t/now) (t/weeks 1)))] (case (:edition config) - "daily" (filter (fn [article] (>= (:published-date article) daily)) articles) - "weekly" (filter (fn [article] (>= (:published-date article) weekly)) articles) + "daily" (filter (fn [article] (and (not (nil? (:published-date article))) (>= (:published-date article) daily))) articles) + "weekly" (filter (fn [article] (and (not (nil? (:published-date article))) (>= (:published-date article) weekly))) articles) :else articles))) @@ -49,17 +49,30 @@ ) articles)) +(defn order-published + [articles] + (reverse (sort-by :published-date articles))) + + (defn get-articles [] ;; Get all feeds from config -> feeds - (reverse (sort-by :published-date (-> + (-> (reduce (fn [feeds feed-url] - (conj feeds - (parse-url feed-url {:insecure? true :throw-exceptions false})) - ) [] (:feeds config)) + ; Read feed + (let [feed (parse-url feed-url {:insecure? true :throw-exceptions false})] + ; Check is not null + (if (not (nil? feed)) + ; Add feed + (conj feeds feed) + ; Alert fail + (prn (str "Error with '" feed-url) "'")))) + [] (:feeds config)) zip-feeds-in-articles datetimes-to-unixtime filter-edition + order-published add-cover-article - add-datetimes-formatter)))) \ No newline at end of file + add-datetimes-formatter + )) \ No newline at end of file