From b9dae2812dc6d168b45b2ede51dc1e2a8aebcbd4 Mon Sep 17 00:00:00 2001 From: Andros Fenollosa Date: Sat, 4 Sep 2021 09:37:48 +0200 Subject: [PATCH] Fix exception and update version 1.1.3 --- project.clj | 2 +- src/rsspaper/feeds.clj | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/project.clj b/project.clj index 9ca5de0..32e8a40 100644 --- a/project.clj +++ b/project.clj @@ -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" diff --git a/src/rsspaper/feeds.clj b/src/rsspaper/feeds.clj index e66ffe2..9cd34cf 100644 --- a/src/rsspaper/feeds.clj +++ b/src/rsspaper/feeds.clj @@ -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 #"].*?property=\"og:image(?::url)?\".*?content=\"(.*?)\".*?>|].*?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 #"].*?property=\"og:image(?::url)?\".*?content=\"(.*?)\".*?>|].*?content=\"(.*?)\".*?property=\"og:image(?::url)?\".*?>" html)) url-first-image (second (re-find #"[\s\S]+]+src=\"([^\">]+)\"|id=['\"] ?main ?['\"]>[\s\S]+]+src=\"([^\">]+)\"|class=['\"] ?main ?[\'\"]>[\s\S]+]+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))