* nnslashdot.el (nnslashdot-request-list): Parse new html.
authorLars Magne Ingebrigtsen <larsi@gnus.org>
Fri, 17 May 2002 19:11:24 +0000 (19:11 +0000)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Fri, 17 May 2002 19:11:24 +0000 (19:11 +0000)
(nnslashdot-use-front-page): New variable.
(nnslashdot-request-list): Use it.

* mm-url.el (mm-url-timeout): New variable.
(mm-url-retries): Ditto.
(mm-url-insert): Use it.

lisp/ChangeLog
lisp/mm-url.el
lisp/nnslashdot.el

index 34430b4..984cb59 100644 (file)
@@ -1,3 +1,13 @@
+2002-05-17  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+       * nnslashdot.el (nnslashdot-request-list): Parse new html.
+       (nnslashdot-use-front-page): New variable.
+       (nnslashdot-request-list): Use it.
+
+       * mm-url.el (mm-url-timeout): New variable.
+       (mm-url-retries): Ditto.
+       (mm-url-insert): Use it.
+
 2002-05-16  Simon Josefsson  <jas@extundo.com>
 
        * gnus-sum.el (gnus-simplify-all-whitespace): New function.
index 561f89a..f578755 100644 (file)
@@ -297,20 +297,39 @@ This is taken from RFC 2396.")
            args (append mm-url-arguments (list url))))
     (apply 'call-process program nil t nil args)))
 
+(defvar mm-url-timeout 30
+  "The number of seconds before timing out an URL fetch.")
+
+(defvar mm-url-retries 10
+  "The number of retries after timing out when fetching an URL.")
+
 (defun mm-url-insert (url &optional follow-refresh)
   "Insert the contents from an URL in the current buffer.
 If FOLLOW-REFRESH is non-nil, redirect refresh url in META."
-  (if follow-refresh
-      (save-restriction
-       (narrow-to-region (point) (point))
-       (mm-url-insert-file-contents url)
-       (goto-char (point-min))
-       (when (re-search-forward
-              "<meta[ \t\r\n]*http-equiv=\"Refresh\"[^>]*URL=\\([^\"]+\\)\"" nil t)
-         (let ((url (match-string 1)))
-           (delete-region (point-min) (point-max))
-           (mm-url-insert url t))))
-    (mm-url-insert-file-contents url)))
+  (let ((times mm-url-retries)
+       (done nil)
+       (first t)
+       result)
+    (message "%s" url)
+    (while (and (not (zerop (decf times)))
+               (not done))
+      (with-timeout (mm-url-timeout)
+       (unless first
+         (message "Trying again (%s)..." (- mm-url-retries times)))
+       (setq first nil)
+       (if follow-refresh
+           (save-restriction
+             (narrow-to-region (point) (point))
+             (mm-url-insert-file-contents url)
+             (goto-char (point-min))
+             (when (re-search-forward
+                    "<meta[ \t\r\n]*http-equiv=\"Refresh\"[^>]*URL=\\([^\"]+\\)\"" nil t)
+               (let ((url (match-string 1)))
+                 (delete-region (point-min) (point-max))
+                 (setq result (mm-url-insert url t)))))
+         (setq result (mm-url-insert-file-contents url)))
+       (setq done t)))
+    result))
 
 (defun mm-url-decode-entities ()
   "Decode all HTML entities."
index 250349d..b5b1bfc 100644 (file)
@@ -53,6 +53,9 @@
 (defvoo nnslashdot-backslash-url "http://slashdot.org/slashdot.xml"
   "Where nnslashdot will fetch the stories from.")
 
+(defvoo nnslashdot-use-front-page nil
+  "Use the front page in addition to the backslash page.")
+
 (defvoo nnslashdot-threshold -1
   "The article threshold.")
 
 (deffoo nnslashdot-request-list (&optional server)
   (nnslashdot-possibly-change-server nil server)
   (let ((number 0)
+       (first nnslashdot-use-front-page)
        sid elem description articles gname)
     (condition-case why
        ;; First we do the Ultramode to get info on all the latest groups.
              (goto-char (point-max))
              (widen)))
          ;; Then do the older groups.
-         (while (> (- nnslashdot-group-number number) 0)
+         (while (or first
+                    (> (- nnslashdot-group-number number) 0))
+           (setq first nil)
            (mm-with-unibyte-buffer
              (let ((case-fold-search t))
                (mm-url-insert (format nnslashdot-active-url number) t)
                (goto-char (point-min))
                (while (re-search-forward
-                       "article.pl\\?sid=\\([^&]+\\).*<b>\\([^<]+\\)</b>"
+                       "article.pl\\?sid=\\([^&]+\\).*>\\([^<]+\\)</a>"
                        nil t)
                  (setq sid (match-string 1)
                        description
                        (mm-url-decode-entities-string (match-string 2)))
                  (forward-line 1)
-                 (when (re-search-forward "<b>\\([0-9]+\\)</b>" nil t)
-                   (setq articles (string-to-number (match-string 1))))
+                 (when (re-search-forward "with \\([0-9]+\\) comment" nil t)
+                   (setq articles (1+ (string-to-number (match-string 1)))))
                  (setq gname (concat description " (" sid ")"))
                  (if (setq elem (assoc gname nnslashdot-groups))
                      (setcar (cdr elem) articles)