;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with this program; if not, you can either send email to this
-;; program's maintainer or write to: The Free Software Foundation,
-;; Inc.; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+;; along with GNU Emacs; see the file COPYING. If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; * mixi-search-bbses
;; * mixi-get-comments
;; * mixi-get-new-comments
+;; * mixi-get-new-bbs-comments
;; * mixi-get-messages
-;; * mixi-get-introductions
+;; * mixi-get-introductions (broken)
;; * mixi-get-news
;;
;; APIs for posting:
(autoload 'w3m-retrieve "w3m")
(autoload 'url-retrieve-synchronously "url"))
+(defconst mixi-revision "$Revision: 1.174 $")
+
(defgroup mixi nil
"API library for accessing to mixi."
:group 'hypermedia)
(defconst mixi-post-key-regexp
"<input type=\"?hidden\"? name=\"?post_key\"? +value=\"\\([a-z0-9]+\\)\"")
(defconst mixi-post-succeed-regexp
- "<b>\\(ºîÀ®\\|½ñ¤¹þ¤ß\\)¤¬´°Î»¤·¤Þ¤·¤¿¡£È¿±Ç¤Ë»þ´Ö¤¬¤«¤«¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¤Î¤Ç¡¢É½¼¨¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¾¯¡¹¤ªÂÔ¤Á¤¯¤À¤µ¤¤¡£</b>")
+ "<p\\(\\| class=\"messageAlert\"\\)>\\(ºîÀ®\\|½ñ¤¹þ¤ß\\)¤¬´°Î»¤·¤Þ¤·¤¿¡£È¿±Ç¤Ë»þ´Ö¤¬¤«¤«¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¤Î¤Ç¡¢É½¼¨¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¾¯¡¹¤ªÂÔ¤Á¤¯¤À¤µ¤¤¡£</p>")
;; FIXME: Support photos.
;;;###autoload
"<dt>³«ºÅ¾ì½ê</dt>
<dd>\\(.+\\)</dd>")
(defconst mixi-event-owner-regexp
- "<dt><a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*\\)</a></dt>")
+ "<dt>\\((mixi Âà²ñºÑ)\\|<a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*\\)</a>\\)</dt>")
(defconst mixi-event-owner-seceded-regexp
- "<dt>\\((mixi Âà²ñºÑ)\\)</dt>")
+ "(mixi Âà²ñºÑ)")
(defconst mixi-event-detail-regexp
"<dd>\\(\\(.\\|\r?\n\\)*?\\)</dd>
</dl>")
(mixi-event-set-place event (match-string 1))
(mixi-realization-error 'cannot-find-place event))
(if (re-search-forward mixi-event-owner-regexp nil t)
- (mixi-event-set-owner event (mixi-make-friend (match-string 1)
- (match-string 2)))
- (if (re-search-forward mixi-event-owner-seceded-regexp nil t)
- (mixi-event-set-owner event
- (mixi-make-friend nil (match-string 1)))
- (mixi-realization-error 'cannot-find-owner event)))
+ (let ((seceded-or-not (match-string 1))
+ (id (match-string 2))
+ (nick (match-string 3)))
+ (if (string= mixi-event-owner-seceded-regexp seceded-or-not)
+ (mixi-event-set-owner event
+ (mixi-make-friend nil seceded-or-not))
+ (mixi-event-set-owner event (mixi-make-friend id nick))))
+ (mixi-realization-error 'cannot-find-owner event))
(if (re-search-forward mixi-event-detail-regexp nil t)
(mixi-event-set-detail event (match-string 1))
(mixi-realization-error 'cannot-find-detail event))
\\|\\)</span>
<span class=\"commentTitleDate\">\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\)</span>
-
-
-?
</dt>
-
-
-
-
-
-
-
-
-
-
-?
++
<dd>
\\(\\(.\\|\r?\n\\)*?\\)
</dd>
diary)))
items))))
+(defmacro mixi-new-bbs-comment-list-page ()
+ `(concat "/new_bbs_comment.pl?page=%d"))
+
+(defconst mixi-new-bbs-comment-list-regexp
+ "<a href=\"?view_\\(bbs\\|event\\)\\.pl\\?id=\\([0-9]+\\)&comment_count=\\([0-9]+\\)&comm_id=\\([0-9]+\\)\"?>")
+
+;;;###autoload
+(defun mixi-get-new-bbs-comments (&optional range)
+ "Get new BBS comments."
+ (let ((items (mixi-get-matched-items (mixi-new-bbs-comment-list-page)
+ mixi-new-bbs-comment-list-regexp
+ range)))
+ (delq nil
+ (mapcar (lambda (item)
+ (let ((name (nth 0 item)))
+ (when (string= name "bbs")
+ (setq name "topic"))
+ (let ((make-func (intern (concat "mixi-make-" name)))
+ (comment-count-func
+ (intern (concat "mixi-" name "-comment-count")))
+ (set-comment-count-func
+ (intern (concat "mixi-" name
+ "-set-comment-count"))))
+ (let* ((bbs (funcall make-func
+ (mixi-make-community (nth 3 item))
+ (nth 1 item)))
+ (comment-count (funcall comment-count-func bbs))
+ (count (string-to-number (nth 2 item))))
+ (when (or (null comment-count)
+ (< comment-count count))
+ (funcall set-comment-count-func bbs count)
+ bbs)))))
+ items))))
+
(defun mixi-post-diary-comment-page (diary)
(concat "/add_comment.pl?&diary_id=" (mixi-diary-id diary)))