Fix nul date

This commit is contained in:
Andros Fenollosa 2021-07-18 12:50:54 +02:00
parent 1e9fd086c0
commit 03447a2f8c
2 changed files with 22 additions and 11 deletions

View File

@ -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

View File

@ -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))))
add-datetimes-formatter
))