Update feeds.clj

This commit is contained in:
Andros Fenollosa 2021-07-31 11:56:47 +02:00 committed by GitHub
parent 993606aae8
commit d4096f3dcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,12 +42,11 @@
(map (fn [article] (map (fn [article]
(let [url-article (get-in article [:feed :link]) (let [url-article (get-in article [:feed :link])
html (:body (client/get url-article {:insecure? true})) html (:body (client/get url-article {:insecure? true}))
first-content (second (re-find #"<meta.*content=\"([^\">]+)\"[^>].*property=\"og:image(?::url)?\".*>" html)) url-og-image (second (re-find #"<meta[^>].*?[^>]property=\"og:image(?::url)?\".*?[^>]content=\"(.*?)\".*?>|<meta[^>].*?[^>]content=\"(.*?)\".*?[^>]property=\"og:image(?::url)?\".*?>" html))
second-content (second (re-find #"<meta.*property=\"og:image(?::url)?\"[^>].*content=\"([^\">]+)\".*>" html)) url-first-image (second (re-find #"(<main|id=\".*main.*\"|class=\".*main.*\").*<img[^>]+src=\"([^\">]+)\"" html))
first-image (second (re-find #"(<main|id=\".*main.*\"|class=\".*main.*\").*<img[^>]+src=\"([^\">]+)\"" html)) images [url-og-image url-first-image]
images [first-content second-content first-image] url-final-image (first (filter (fn [item] (not (nil? item))) images))]
final-image (first (filter (fn [item] (not (nil? item))) images))] (assoc article :cover url-final-image))) articles))
(assoc article :cover final-image))) articles))
(defn order-published (defn order-published
[articles] [articles]