* mixi.el (mixi-log-list-regexp): Fix regexp.
[elisp/mixi.git] / mixi.el
diff --git a/mixi.el b/mixi.el
index b01e5f6..69dfacf 100644 (file)
--- a/mixi.el
+++ b/mixi.el
@@ -227,7 +227,9 @@ Increase this value when unexpected error frequently occurs."
     (funcall mixi-retrieve-function url post-data)))
 
 (defmacro mixi-expand-url (url)
-  `(concat mixi-url ,url))
+  `(if (string-match (concat "^" mixi-url) ,url)
+       ,url
+     (concat mixi-url ,url)))
 
 (defun mixi-w3-retrieve (url &optional post-data)
   "Retrieve the URL and return gotten strings."
@@ -352,7 +354,8 @@ Increase this value when unexpected error frequently occurs."
     (catch 'end
       (while (or (null max-numbers) (< (length ids) max-numbers))
        (with-mixi-retrieve (format url page)
-         (let ((pos 0))
+         (let ((pos 0)
+               found)
            (while (and (string-match regexp buffer pos)
                        (or (null max-numbers) (< (length ids) max-numbers)))
              (let ((num 1)
@@ -360,11 +363,11 @@ Increase this value when unexpected error frequently occurs."
                (while (match-string num buffer)
                  (setq list (cons (match-string num buffer) list))
                  (incf num))
-               (when (member (reverse list) ids)
-                 (throw 'end ids))
-               (setq ids (cons (reverse list) ids))
+               (when (not (member (reverse list) ids))
+                 (setq found t)
+                 (setq ids (cons (reverse list) ids)))
                (setq pos (match-end (1- num)))))
-           (when (eq pos 0)
+           (when (not found)
              (throw 'end ids))))
        (incf page)))
     ;; FIXME: Sort? Now order by newest.
@@ -872,7 +875,7 @@ Increase this value when unexpected error frequently occurs."
   `(concat "/show_log.pl"))
 
 (defconst mixi-log-list-regexp
-  "\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\) <a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.+\\)</a><br>")
+  "\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\) <a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*\\)</a></li>")
 
 (defun mixi-get-logs (&optional max-numbers)
   "Get logs."
@@ -1074,7 +1077,7 @@ Increase this value when unexpected error frequently occurs."
   "<td BGCOLOR=#F2DDB7><font COLOR=#996600>³«ÀßÆü</font></td>\n<td>\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü</td>")
 ;; FIXME: Care when the owner has seceded.
 (defconst mixi-community-owner-regexp
-  "<td BGCOLOR=#F2DDB7><font COLOR=#996600>´ÉÍý¿Í</font></td>\n<td>\n\n<a href=\"\\(home\\.pl\\|show_friend\\.pl\\?id=\\([0-9]+\\)\\)\">\n\\(.+\\)</a>")
+  "<td BGCOLOR=#F2DDB7><font COLOR=#996600>´ÉÍý¿Í</font></td>\n<td>\n\n<a href=\"\\(home\\.pl\\|show_friend\\.pl\\?id=\\([0-9]+\\)\\)\">\n\\(.*\\)</a>")
 (defconst mixi-community-category-regexp
   "<td BGCOLOR=#F2DDB7><font COLOR=#996600>¥«¥Æ¥´¥ê</font></td>\n<td>\\([^<]+\\)</td>")
 (defconst mixi-community-members-regexp
@@ -1309,9 +1312,9 @@ Increase this value when unexpected error frequently occurs."
   "<td bgcolor=\"#fff4e0\">&nbsp;\\([^<]+\\)</td>")
 ;; FIXME: Remove `¤µ¤ó'.
 (defconst mixi-topic-owner-regexp
-  "<td bgcolor=\"#fdf9f2\">&nbsp;<font color=\"#dfb479\"></font>&nbsp;<a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.+\\)\\(¤µ¤ó\\)?</a>")
+  "<td bgcolor=\"#fdf9f2\">&nbsp;<font color=\"#dfb479\"></font>&nbsp;<a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*\\)\\(¤µ¤ó\\)?</a>")
 (defconst mixi-topic-content-regexp
-  "<td class=\"h120\"><table><tr>\\(.+\\)?</tr></table>\\(.+\\)</td>")
+  "<td class=\"h120\"><table><tr>\\(.+\\)?\n?\\(.+\\)?\n?\\(.+\\)?\n?</tr></table>\\(.+\\)</td>")
 
 (defun mixi-topic-realize (topic)
   "Realize a TOPIC."
@@ -1335,7 +1338,7 @@ Increase this value when unexpected error frequently occurs."
                                                  (match-string 2 buffer)))
        (signal 'error (list 'cannot-find-owner topic)))
       (if (string-match mixi-topic-content-regexp buffer)
-         (mixi-topic-set-content topic (match-string 2 buffer))
+         (mixi-topic-set-content topic (match-string 4 buffer))
        (signal 'error (list 'cannot-find-content topic))))
     (mixi-object-touch topic)))
 
@@ -1486,8 +1489,8 @@ Increase this value when unexpected error frequently occurs."
 <td ALIGN=center BGCOLOR=#FDF9F2 WIDTH=430>
 <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"410\">
 <tr>
-<td>
-<a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.+\\)</a>
+\\(<td>\\)
+<a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*\\)</a>
 
 \\(<font color=\"#f2ddb7\">|</font> <a href=[^>]+>ºï½ü</a>
 
@@ -1506,7 +1509,7 @@ Increase this value when unexpected error frequently occurs."
 </td></tr></table>")
 
 (defun mixi-topic-comment-list-page (topic)
-  (concat "/view_bbs.pl?page=%d"
+  (concat "/view_bbs.pl?page=all"
          "&id=" (mixi-topic-id topic)
          "&comm_id=" (mixi-community-id (mixi-topic-community topic))))
 
@@ -1516,13 +1519,14 @@ Increase this value when unexpected error frequently occurs."
 <td rowspan=\"2\" width=\"110\" bgcolor=\"#f2ddb7\" align=\"center\" nowrap>
 \\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü<br>
 \\([0-9]+\\):\\([0-9]+\\)<br>
-</td>
+\\(<input type=\"checkbox\" name=\"comment_id\" value=\".+\">
+\\|\\)</td>
 <td bgcolor=\"#fdf9f2\">&nbsp;<font color=\"#f8a448\">
 <b>[^<]+</b>:</font>&nbsp;
 \\(
-\\|\\)<a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.+\\)</a>
+\\|\\) *<a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*\\)</a>
 
-\\(
+?\\(
 
 \\|\\)</td>
 </tr>
@@ -1552,7 +1556,7 @@ Increase this value when unexpected error frequently occurs."
                  (funcall list-page parent) max-numbers regexp)))
       (mapcar (lambda (item)
                (mixi-make-comment parent (mixi-make-friend
-                                          (nth 6 item) (nth 7 item))
+                                          (nth 7 item) (nth 8 item))
                                   (encode-time
                                    0
                                    (string-to-number (nth 4 item))
@@ -1560,7 +1564,7 @@ Increase this value when unexpected error frequently occurs."
                                    (string-to-number (nth 2 item))
                                    (string-to-number (nth 1 item))
                                    (string-to-number (nth 0 item)))
-                                  (nth 9 item)))
+                                  (nth 10 item)))
              items))))
 
 (defmacro mixi-new-comment-list-page ()
@@ -1575,10 +1579,8 @@ Increase this value when unexpected error frequently occurs."
                                       max-numbers
                                       mixi-new-comment-list-regexp)))
     (mapcar (lambda (item)
-             (let ((diary (mixi-make-diary
-                           (mixi-make-friend (nth 1 item))
-                           (nth 0 item))))
-               (mixi-get-comments diary)))
+             ;; FIXME: Return comments?
+             (mixi-make-diary (mixi-make-friend (nth 1 item)) (nth 0 item)))
            items)))
 
 ;; Message object.
@@ -1619,7 +1621,7 @@ Increase this value when unexpected error frequently occurs."
           "&box=" (mixi-message-box ,message)))
 
 (defconst mixi-message-owner-regexp
-  "<font COLOR=#996600>º¹½Ð¿Í</font>&nbsp;:&nbsp;<a HREF=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.+\\)</a>")
+  "<font COLOR=#996600>º¹½Ð¿Í</font>&nbsp;:&nbsp;<a HREF=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*\\)</a>")
 (defconst mixi-message-title-regexp
   "<font COLOR=#996600>·ï¡¡Ì¾</font>&nbsp;:&nbsp;\\(.+\\)
 </td>")
@@ -1777,7 +1779,7 @@ Increase this value when unexpected error frequently occurs."
 (defconst mixi-introduction-list-regexp
   "<tr bgcolor=#FFFFFF>
 <td WIDTH=150 background=http://img\\.mixi\\.jp/img/bg_line\\.gif align=\"center\"><a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\"><img src=\".+\" border=0><br>
-\\(.+\\)</td></a>
+\\(.*\\)</td></a>
 
 <td WIDTH=480>
 \\(´Ø·¸¡§.+<br>
@@ -1794,7 +1796,7 @@ Increase this value when unexpected error frequently occurs."
 (defconst mixi-my-introduction-list-regexp
   "<tr bgcolor=#FFFFFF>
 <td WIDTH=150 background=http://img\\.mixi\\.jp/img/bg_line\\.gif align=\"center\"><a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\"><img src=\".+\" border=0><br>
-\\(.+\\)</td></a>
+\\(.*\\)</td></a>
 
 
 <td WIDTH=480>