|
@@ -8,35 +8,37 @@
|
|
|
(defparameter *rss-change-rate* 0.1 "Refresh period adjustment rata")
|
|
(defparameter *rss-change-rate* 0.1 "Refresh period adjustment rata")
|
|
|
|
|
|
|
|
(defun http-default (url)
|
|
(defun http-default (url)
|
|
|
- (let ((uri (quri:uri url)))
|
|
|
|
|
- (quri:render-uri
|
|
|
|
|
- (if (null (quri:uri-scheme uri))
|
|
|
|
|
- (quri:uri (format nil "http://~A" url))
|
|
|
|
|
- uri))))
|
|
|
|
|
|
|
+ (let ((uri (puri:uri url)))
|
|
|
|
|
+ (puri:render-uri
|
|
|
|
|
+ (if (null (puri:uri-scheme uri))
|
|
|
|
|
+ (puri:uri (format nil "http://~A" url))
|
|
|
|
|
+ uri)
|
|
|
|
|
+ nil)))
|
|
|
|
|
|
|
|
(defun get-by-tag (node tag)
|
|
(defun get-by-tag (node tag)
|
|
|
(nreverse (plump:get-elements-by-tag-name node tag)))
|
|
(nreverse (plump:get-elements-by-tag-name node tag)))
|
|
|
|
|
|
|
|
(defun url-parse (url)
|
|
(defun url-parse (url)
|
|
|
(plump:parse (flexi-streams:octets-to-string
|
|
(plump:parse (flexi-streams:octets-to-string
|
|
|
- (dex:get (http-default url) :force-binary t) :external-format :utf-8)))
|
|
|
|
|
|
|
+ (drakma:http-request (http-default url) :force-binary t) :external-format :utf-8)))
|
|
|
|
|
|
|
|
(defun find-rss-url (url)
|
|
(defun find-rss-url (url)
|
|
|
- (ignore-errors
|
|
|
|
|
|
|
+ (handler-case
|
|
|
(multiple-value-bind (body status headers uri stream)
|
|
(multiple-value-bind (body status headers uri stream)
|
|
|
- (dex:get (http-default url) :force-binary t)
|
|
|
|
|
|
|
+ (drakma:http-request (http-default url) :force-binary t)
|
|
|
(declare (ignore status stream))
|
|
(declare (ignore status stream))
|
|
|
(let ((root (plump:parse (flexi-streams:octets-to-string body :external-format :utf-8)))
|
|
(let ((root (plump:parse (flexi-streams:octets-to-string body :external-format :utf-8)))
|
|
|
- (content-type (gethash "content-type" headers)))
|
|
|
|
|
|
|
+ (content-type (aget :content-type headers)))
|
|
|
(cond
|
|
(cond
|
|
|
((alexandria:starts-with-subseq "text/html" content-type)
|
|
((alexandria:starts-with-subseq "text/html" content-type)
|
|
|
(loop for link in (get-by-tag root "link")
|
|
(loop for link in (get-by-tag root "link")
|
|
|
when (string= "application/rss+xml" (plump:attribute link "type"))
|
|
when (string= "application/rss+xml" (plump:attribute link "type"))
|
|
|
- do (return (quri:render-uri
|
|
|
|
|
- (quri:merge-uris (quri:uri (plump:attribute link "href"))
|
|
|
|
|
- uri)))))
|
|
|
|
|
|
|
+ do (return (puri:render-uri
|
|
|
|
|
+ (puri:merge-uris (puri:uri (plump:attribute link "href"))
|
|
|
|
|
+ uri) nil))))
|
|
|
((string= "rss" (plump:tag-name (plump:first-element root)))
|
|
((string= "rss" (plump:tag-name (plump:first-element root)))
|
|
|
- (quri:render-uri uri)))))))
|
|
|
|
|
|
|
+ (puri:render-uri uri nil)))))
|
|
|
|
|
+ (error (e) (log:error e))))
|
|
|
|
|
|
|
|
(defun build-feed (url)
|
|
(defun build-feed (url)
|
|
|
(let ((root (url-parse url)))
|
|
(let ((root (url-parse url)))
|