From: Lars Magne Ingebrigtsen Date: Fri, 17 May 2002 19:11:24 +0000 (+0000) Subject: * nnslashdot.el (nnslashdot-request-list): Parse new html. X-Git-Url: http://cgit.sxemacs.org/?a=commitdiff_plain;h=319437fa58fc4b0efac92463e249b9a2a6813362;p=gnus * 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. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 34430b4a9..984cb5933 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,13 @@ +2002-05-17 Lars Magne Ingebrigtsen + + * 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 * gnus-sum.el (gnus-simplify-all-whitespace): New function. diff --git a/lisp/mm-url.el b/lisp/mm-url.el index 561f89aea..f57875564 100644 --- a/lisp/mm-url.el +++ b/lisp/mm-url.el @@ -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 - "]*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 + "]*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." diff --git a/lisp/nnslashdot.el b/lisp/nnslashdot.el index 250349d79..b5b1bfc37 100644 --- a/lisp/nnslashdot.el +++ b/lisp/nnslashdot.el @@ -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.") @@ -292,6 +295,7 @@ (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. @@ -321,20 +325,22 @@ (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=\\([^&]+\\).*\\([^<]+\\)" + "article.pl\\?sid=\\([^&]+\\).*>\\([^<]+\\)" nil t) (setq sid (match-string 1) description (mm-url-decode-entities-string (match-string 2))) (forward-line 1) - (when (re-search-forward "\\([0-9]+\\)" 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)