Parcourir la source

RSS replace dex:get with drakma:http-request

Innokenty Enikev il y a 10 ans
Parent
commit
e7fbb3af37
1 fichiers modifiés avec 15 ajouts et 13 suppressions
  1. 15 13
      rss.lisp

+ 15 - 13
rss.lisp

@@ -8,35 +8,37 @@
 (defparameter *rss-change-rate* 0.1 "Refresh period adjustment rata")
 
 (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)
   (nreverse (plump:get-elements-by-tag-name node tag)))
 
 (defun url-parse (url)
   (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)
-  (ignore-errors
+  (handler-case
     (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))
       (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
           ((alexandria:starts-with-subseq "text/html" content-type)
            (loop for link in (get-by-tag root "link")
               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)))
-           (quri:render-uri uri)))))))
+           (puri:render-uri uri nil)))))
+    (error (e) (log:error e))))
 
 (defun build-feed (url)
   (let ((root (url-parse url)))