;; mixi.el --- API libraries for accessing to mixi -*- coding: euc-jp -*-
-;; Copyright (C) 2005,2006 OHASHI Akira
+;; Copyright (C) 2005, 2006, 2007 OHASHI Akira
;; Author: OHASHI Akira <bg66@koka-in.org>
;; Keywords: hypermedia
(defun mixi-logout ()
(mixi-retrieve "/logout.pl"))
+(defconst mixi-login-form "<form action=\"/login.pl\" method=\"post\">")
+
(defmacro with-mixi-retrieve (url &rest body)
`(with-current-buffer (get-buffer-create mixi-temp-buffer-name)
(when ,url
(erase-buffer)
(insert (mixi-retrieve ,url))
(goto-char (point-min))
- (when (search-forward
- "<form action=\"login.pl\" method=\"post\">" nil t)
+ (when (search-forward mixi-login-form nil t)
(mixi-login)
(erase-buffer)
(insert (mixi-retrieve ,url))))
(erase-buffer)
(insert (mixi-post-form ,url ,fields))
(goto-char (point-min))
- (when (search-forward
- "<form action=\"login.pl\" method=\"post\">" nil t)
+ (when (search-forward mixi-login-form nil t)
(mixi-login)
(erase-buffer)
(insert (mixi-post-form ,url ,fields))))
(buffer-string)))
;; stolen (and modified) from w3m.el
+(defconst mixi-entity-alist '(("gt" . ">")
+ ("lt" . "<")
+ ("amp" . "&"))
+ "Alist of html character entities and values.")
+
+;; stolen (and modified) from w3m.el
+(defun mixi-encode-specials-string (str)
+ "Encode special characters in the string STR."
+ (let ((pos 0)
+ (buf))
+ (while (string-match "[<>&]" str pos)
+ (setq buf
+ (cons ";"
+ (cons (car (rassoc (match-string 0 str) mixi-entity-alist))
+ (cons "&"
+ (cons (substring str pos (match-beginning 0))
+ buf))))
+ pos (match-end 0)))
+ (if buf
+ (apply 'concat (nreverse (cons (substring str pos) buf)))
+ str)))
+
+;; stolen (and modified) from w3m.el
(defun mixi-url-encode-string (string)
(apply (function concat)
(mapcar
(aref (cdr friend) 12))
(defun mixi-friend-profile (friend)
- "Return the pforile of FRIEND."
+ "Return the profile of FRIEND."
(unless (mixi-friend-p friend)
(signal 'wrong-type-argument (list 'mixi-friend-p friend)))
(mixi-realize-friend friend)
(when ,friend (concat "&id=" (mixi-friend-id ,friend)))))
(defconst mixi-friend-list-id-regexp
- "<a href=show_friend\\.pl\\?id=\\([0-9]+\\)")
+ "<a href=\"?show_friend\\.pl\\?id=\\([0-9]+\\)\"?")
(defconst mixi-friend-list-nick-regexp
- "<td valign=middle>\\(.+\\)¤µ¤ó([0-9]+)<br />")
+ "<td valign=\"?top\"?>\\(.+\\)¤µ¤ó([0-9]+)")
;;;###autoload
(defun mixi-get-friends (&rest friend-or-range)
(defconst mixi-diary-title-regexp
"<td bgcolor=\"?#FFF4E0\"? width=\"?430\"?> \\([^<]+\\)</td>")
(defconst mixi-diary-content-regexp
- "<td class=\"?h12\"?>\\(\\(.\\|\r?\n\\)*?\\)</td>")
+ "<table border=\"?0\"? cellspacing=\"?0\"? cellpadding=\"?3\"? width=\"?410\"?>\\(\\(.\\|\r?\n\\)*?\\)\\(\t\\|</tr>\r?\n\\)</table>")
(defun mixi-realize-diary (diary &optional page)
"Realize a DIARY."
(defconst mixi-diary-list-regexp
"<tr VALIGN=top>
-<td ALIGN=center ROWSPAN=3 NOWRAP bgcolor=#F2DDB7><font COLOR=#996600>\\([0-9]+\\)·î\\([0-9]+\\)Æü<br>\\([0-9]+\\):\\([0-9]+\\)</font>\\(<br><input type=\"checkbox\" name=\"diary_id\" value=\"[0-9]+\">\\|\\)</td>
+<td ALIGN=center ROWSPAN=3 NOWRAP bgcolor=#F2DDB7><font COLOR=#996600>\\([0-9]+\\)ǯ<br />\\([0-9]+\\)·î\\([0-9]+\\)Æü<br>\\([0-9]+\\):\\([0-9]+\\)</font>\\(<br><input type=\"checkbox\" name=\"diary_id\" value=\"[0-9]+\">\\|\\)</td>
<td bgcolor=\"#FFF4E0\"> <a href=\"view_diary\\.pl\\?id=\\([0-9]+\\)&owner_id=[0-9]+\">\\(.*\\)</a></td>")
;;;###autoload
(signal 'wrong-type-argument (list 'mixi-friend-p friend)))
(let ((items (mixi-get-matched-items (mixi-diary-list-page friend)
mixi-diary-list-regexp
- range))
- (year (nth 5 (decode-time (current-time))))
- (month (nth 4 (decode-time (current-time)))))
+ range)))
(mapcar (lambda (item)
- (let ((month-of-item (string-to-number (nth 0 item))))
- (when (> month-of-item month)
- (decf year))
- (setq month month-of-item)
- (mixi-make-diary friend (nth 5 item) nil
- (encode-time
- 0 (string-to-number (nth 3 item))
- (string-to-number (nth 2 item))
- (string-to-number (nth 1 item))
- month year)
- (nth 6 item))))
+ (mixi-make-diary friend (nth 6 item) nil
+ (encode-time
+ 0 (string-to-number (nth 4 item))
+ (string-to-number (nth 3 item))
+ (string-to-number (nth 2 item))
+ (string-to-number (nth 1 item))
+ (string-to-number (nth 0 item)))
+ (nth 7 item)))
items))))
(defmacro mixi-new-diary-list-page ()
<tr>
<td BGCOLOR=#FDF9F2><font COLOR=#996600>ËÜ Ê¸</font></td>
-<td COLSPAN=2 BGCOLOR=#FFFFFF>\\(.*\\)</td></tr>
+<td COLSPAN=2 BGCOLOR=#FFFFFF width=\"380\">\\(.*\\)</td></tr>
<tr>
`(concat "/add_diary.pl"))
(defconst mixi-post-key-regexp
- "<input type=\"?hidden\"? name=\"?post_key\"? value=\"\\([a-z0-9]+\\)\">")
+ "<input type=\"?hidden\"? name=\"?post_key\"? +value=\"\\([a-z0-9]+\\)\"")
(defconst mixi-post-succeed-regexp
"<b>\\(ºîÀ®\\|½ñ¤¹þ¤ß\\)¤¬´°Î»¤·¤Þ¤·¤¿¡£È¿±Ç¤Ë»þ´Ö¤¬¤«¤«¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¤Î¤Ç¡¢É½¼¨¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¾¯¡¹¤ªÂÔ¤Á¤¯¤À¤µ¤¤¡£</b>")
<a href=\"\\(home\\.pl\\|show_friend\\.pl\\?id=\\([0-9]+\\)\\)\">\\(.*\\)</a>")
(defconst mixi-community-category-regexp
"<td bgcolor=\"?#F2DDB7\"? width=\"?80\"?><font color=\"?#996600\"?>¥«¥Æ¥´¥ê</font></td>
-<td width=\"?345\"?>\\([^<]+\\)</td>")
+<td width=\"?345\"?>
+\\(.+\\)
+</td>")
(defconst mixi-community-members-regexp
"<td bgcolor=\"?#F2DDB7\"? width=\"?80\"?><font color=\"?#996600\"?>¥á¥ó¥Ð¡¼¿ô</font></td>
-<td width=\"?345\"?>\\([0-9]+\\)¿Í</td></tr>")
+<td width=\"?345\"?>
+\\([0-9]+\\)¿Í
+</td>")
(defconst mixi-community-open-level-regexp
"<td bgcolor=\"?#F2DDB7\"? width=\"?80\"?><font color=\"?#996600\"?>»²²Ã¾ò·ï¤È<br />¸ø³«¥ì¥Ù¥ë</font></td>
-<td width=\"?345\"?>\\(.+\\)</td></tr>")
+<td width=\"?345\"?>
+\\(.+\\)
+</td>")
(defconst mixi-community-authority-regexp
"<td bgcolor=\"?#F2DDB7\"? width=\"?80\"?><font color=\"?#996600\"?>¥È¥Ô¥Ã¥¯ºîÀ®¤Î¸¢¸Â</font></td>
-<td width=\"?345\"?>\\(.+\\)</td></tr>")
+<td width=\"?345\"?>
+\\(.+\\)
+
+
+</td>")
(defconst mixi-community-description-regexp
"<td class=\"?h120\"? width=\"?345\"?>\\(.+\\)</td>")
(when ,friend (concat "&id=" (mixi-friend-id ,friend)))))
(defconst mixi-community-list-id-regexp
- "<a href=view_community\\.pl\\?id=\\([0-9]+\\)")
+ "<a href=\"?view_community\\.pl\\?id=\\([0-9]+\\)\"?")
(defconst mixi-community-list-name-regexp
- "<td valign=middle>\\(.+\\)([0-9]+)</td>")
+ "<td valign=\"?top\"?>\\(.+\\)([0-9]+)")
;;;###autoload
(defun mixi-get-communities (&rest friend-or-range)
(defconst mixi-topic-owner-regexp
"<td bgcolor=\"#fdf9f2\"> <font color=\"#dfb479\"></font> <a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*?\\)\\(¤µ¤ó\\)?</a>")
(defconst mixi-topic-content-regexp
- "<table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\"><tr><td class=\"h120\"><table><tr>\\(<td width=\"130\" height=\"140\" align=\"center\" valign=\"middle\"><a href=\"javascript:void(0)\" onClick=\"MM_openBrWindow('show_bbs_picture\\.pl\\?id=[0-9]+&comm_id=[0-9]+&number=[0-9]+','pict','width=680,height=660,toolbar=no,scrollbars=yes,left=5,top=5')\"><img src=\"http://ic[0-9]+\\.mixi\\.jp/[^.]+\\.jpg\" border=\"0\"></a></td>\n\\)*</tr></table>\\(.+\\)</td></tr></table>")
+ "<table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\"><tr><td class=\"h120\" width=\"500\"><table><tr>\\(\\(.\\|\r?\n\\)*?\\)</td></tr></table>")
(defun mixi-realize-topic (topic &optional page)
"Realize a TOPIC."
(match-string 2)))
(mixi-realization-error 'cannot-find-owner topic))
(if (re-search-forward mixi-topic-content-regexp nil t)
- (mixi-topic-set-content topic (match-string 2))
+ (mixi-topic-set-content topic (match-string 1))
(mixi-realization-error 'cannot-find-content topic)))
(mixi-object-touch topic)))
(defconst mixi-event-time-regexp
"<td rowspan=\"?11\"? bgcolor=\"?#FFD8B0\"? align=\"?center\"? valign=\"?top\"? width=\"?110\"?>
?\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü<br>
-?\\([0-9]+\\):\\([0-9]+\\)</td>")
+?\\([0-9]+\\):\\([0-9]+\\)
+</td>")
(defconst mixi-event-title-regexp
"<td bgcolor=\"?#FFF4E0\"?\\( width=\"?410\"?\\)?> \\([^<]+\\)</td>")
(defconst mixi-event-owner-regexp
</td>")
(defconst mixi-event-detail-regexp
"<td bgcolor=\"?#FFFFFF\"? align=\"?center\"? nowrap>¾ÜºÙ</td>
-<td bgcolor=\"?#FFFFFF\"?><table border=\"?0\"? cellspacing=\"?0\"? cellpadding=\"?5\"?><tr><td class=\"?h120\"?>\\(.+\\)</td></tr></table></td>")
+<td bgcolor=\"?#FFFFFF\"? class=\"?h120\"? width=\"?410\"?>
+<div style=\"?padding:5px\"?>\\(.+\\)</div>")
(defconst mixi-event-limit-regexp
"<td bgcolor=\"?#FFFFFF\"? align=\"?center\"? nowrap>Ê罸´ü¸Â</td>
?<td bgcolor=\"?#FFFFFF\"?> \\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü</td>")
;; FIXME: Split regexp to time, owner(id and nick) and contents.
(defconst mixi-diary-comment-list-regexp
-"<td rowspan=\"2\" align=\"center\" width=\"95\" bgcolor=\"#f2ddb7\" nowrap>
+ "<td rowspan=\"2\" align=\"center\" width=\"95\" bgcolor=\"#f2ddb7\" nowrap>
\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü<br>\\([0-9]+\\):\\([0-9]+\\)\\(<br>
<input type=checkbox name=comment_id value=\".+\">
\\|\\)
<td bgcolor=\"#ffffff\">
<table BORDER=0 CELLSPACING=0 CELLPADDING=[35] WIDTH=410>
<tr>
-<td CLASS=h12>
+<td CLASS=h12 width=\"410\">
\\(.+\\)
</td></tr></table>")
<td bgcolor=\"#ffffff\" align=\"center\">
<table border=\"0\" cellspacing=\"0\" cellpadding=\"5\" width=\"500\">
<tr>
-<td class=\"h120\">
-
-\\(.+\\)
+<td class=\"h120\" width=\"500\">
+\\(\\(.\\|\r?\n\\)*?\\)
</td>
</tr>
</table>
<tr>
<td ALIGN=center BGCOLOR=#FFFFFF>
<table BORDER=0 CELLSPACING=0 CELLPADDING=5 WIDTH=500>
-<tr><td CLASS=h120>\\(.+\\)</td></tr>
+<tr>
+<td CLASS=h120 width=\"500\">
+
+\\(.+\\)
+</td>
+</tr>
</table>
</td>
</tr>")
(defconst mixi-message-title-regexp
"<font COLOR=#996600>·ï\\(¡¡\\| \\)̾</font> : \\(.*\\)\n?</td>")
(defconst mixi-message-content-regexp
- "<tr><td CLASS=h120>\\(.*\\)</td></tr>")
+ "<tr><td CLASS=h120 width=\"500\">\\(.*\\)</td></tr>")
(defun mixi-realize-message (message)
"Realize a MESSAGE."
(defconst mixi-news-finished-regexp
- "<td ALIGN=center background=http://img\\.mixi\\.jp/img/bg_line\\.gif> ¿½¤·Ìõ¤´¤¶¤¤¤Þ¤»¤ó¤¬¡¢¤³¤Î¥Ë¥å¡¼¥¹¤Ï·ÇºÜ½ªÎ»¤·¤Þ¤·¤¿¡£</td>")
+ "¿½¤·Ìõ¤´¤¶¤¤¤Þ¤»¤ó¤¬¡¢¤³¤Î¥Ë¥å¡¼¥¹¤Ï·ÇºÜ¤¬½ªÎ»¤·¤¿¤«¡¢URL¤¬´Ö°ã¤Ã¤Æ¤¤¤¤¤ë¤¿¤á¤´Í÷¤¤¤¿¤À¤±¤Þ¤»¤ó¡£</td>")
(defconst mixi-news-title-regexp
"<td HEIGHT=\"46\" STYLE=\"font-weight: bold;font-size: 14px;\" CLASS=\"h130\">\\(.+\\)\\(
\\)?</td>")