Fix exception and update version 1.1.3

This commit is contained in:
Andros Fenollosa 2021-09-04 09:37:48 +02:00
parent 359b88cbc0
commit b9dae2812d
2 changed files with 7 additions and 7 deletions

View File

@ -1,4 +1,4 @@
(defproject rsspaper "1.1.2"
(defproject rsspaper "1.1.3"
:description "RSSpaper"
:url "https://github.com/tanrax/RSSpaper"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"

View File

@ -40,14 +40,14 @@
;; Add cover to article search first image in description
;; Iterate every blog
(map (fn [article]
; User feedback
; User feedback
(prn (str "Looking for cover image for article > " (:link article)))
; Search cover image
(let [url-article (:link article)
html (:body (client/get url-article {:insecure? true}))
url-og-image (second (re-find #"<meta[^>].*?property=\"og:image(?::url)?\".*?content=\"(.*?)\".*?>|<meta[^>].*?content=\"(.*?)\".*?property=\"og:image(?::url)?\".*?>" html))
; Search cover image
(let [url-article (:link article)
html (:body (client/get url-article {:insecure? true :throw-exceptions false}))
url-og-image (second (re-find #"<meta[^>].*?property=\"og:image(?::url)?\".*?content=\"(.*?)\".*?>|<meta[^>].*?content=\"(.*?)\".*?property=\"og:image(?::url)?\".*?>" html))
url-first-image (second (re-find #"<main.*>[\s\S]+<img[^>]+src=\"([^\">]+)\"|id=['\"] ?main ?['\"]>[\s\S]+<img[^>]+src=\"([^\">]+)\"|class=['\"] ?main ?[\'\"]>[\s\S]+<img[^>]+src=\"([^\">]+)\"" html))
images [url-og-image url-first-image]
images [url-og-image url-first-image]
url-final-image (first (filter (fn [item] (not (nil? item))) images))]
(assoc article :cover url-final-image))) articles))