X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=mixi.el;h=9c2d96ac8f3d6bcec2f82ebd28dada67439c230f;hb=392b0c6a3c020e75cf577b6187ceaba3bedb2879;hp=124d34c9f1ac423606eff3b9f510e53520ad2d22;hpb=c6c7071206bc8f987f1791f3bc03ebbe875e3c8e;p=elisp%2Fmixi.git diff --git a/mixi.el b/mixi.el index 124d34c..9c2d96a 100644 --- a/mixi.el +++ b/mixi.el @@ -18,9 +18,9 @@ ;; 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: @@ -39,8 +39,9 @@ ;; * 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: @@ -135,6 +136,8 @@ (autoload 'w3m-retrieve "w3m") (autoload 'url-retrieve-synchronously "url")) +(defconst mixi-revision "$Revision: 1.177 $") + (defgroup mixi nil "API library for accessing to mixi." :group 'hypermedia) @@ -1398,7 +1401,7 @@ Increase this value when unexpected error frequently occurs." (defconst mixi-post-key-regexp "\\(ºîÀ®\\|½ñ¤­¹þ¤ß\\)¤¬´°Î»¤·¤Þ¤·¤¿¡£È¿±Ç¤Ë»þ´Ö¤¬¤«¤«¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¤Î¤Ç¡¢É½¼¨¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¾¯¡¹¤ªÂÔ¤Á¤¯¤À¤µ¤¤¡£") + "\\(ºîÀ®\\|½ñ¤­¹þ¤ß\\)¤¬´°Î»¤·¤Þ¤·¤¿¡£È¿±Ç¤Ë»þ´Ö¤¬¤«¤«¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¤Î¤Ç¡¢É½¼¨¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¾¯¡¹¤ªÂÔ¤Á¤¯¤À¤µ¤¤¡£

") ;; FIXME: Support photos. ;;;###autoload @@ -1456,7 +1459,7 @@ Increase this value when unexpected error frequently occurs." (defconst mixi-community-nodata-regexp "^¥Ç¡¼¥¿¤¬¤¢¤ê¤Þ¤»¤ó") (defconst mixi-community-name-regexp - "
+ "

\\(.*\\)

") (defconst mixi-community-birthday-regexp "
³«ÀßÆü
@@ -1917,9 +1920,9 @@ Increase this value when unexpected error frequently occurs." "
³«ºÅ¾ì½ê
\\(.+\\)
") (defconst mixi-event-owner-regexp - "
\\(.*\\)
") + "
\\((mixi Âà²ñºÑ)\\|\\(.*\\)\\)
") (defconst mixi-event-owner-seceded-regexp - "
\\((mixi Âà²ñºÑ)\\)
") + "(mixi Âà²ñºÑ)") (defconst mixi-event-detail-regexp "
\\(\\(.\\|\r?\n\\)*?\\)
") @@ -1958,12 +1961,14 @@ Increase this value when unexpected error frequently occurs." (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)) @@ -2230,9 +2235,9 @@ Increase this value when unexpected error frequently occurs." (funcall func parent page))) ;; Comment object. -(defun mixi-make-comment (parent owner time content) +(defun mixi-make-comment (parent owner time content &optional count) "Return a comment object." - (cons 'mixi-comment (vector parent owner time content))) + (cons 'mixi-comment (vector parent owner time content count))) (defmacro mixi-comment-p (comment) `(eq (mixi-object-class ,comment) 'mixi-comment)) @@ -2261,6 +2266,12 @@ Increase this value when unexpected error frequently occurs." (signal 'wrong-type-argument (list 'mixi-comment-p comment))) (aref (cdr comment) 3)) +(defun mixi-comment-count (comment) + "Return the count of COMMENT." + (unless (mixi-comment-p comment) + (signal 'wrong-type-argument (list 'mixi-comment-p comment))) + (aref (cdr comment) 4)) + (defun mixi-diary-comment-list-page (diary) (concat "/view_diary.pl?full=1" "&id=" (mixi-diary-id diary) @@ -2270,29 +2281,18 @@ Increase this value when unexpected error frequently occurs." (defconst mixi-diary-comment-list-regexp "\\( \\|\\)\\(.*\\) - +\\( +| ¼«Ê¬¤Î¥³¥á¥ó¥È¤òºï½ü¤¹¤ë +\\|\\) \\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\) - - -? - - - - - - - - - - - - -? ++
-\\(.+\\) -
") +\\(\\(.\\|\r?\n\\)*?\\) + + +
") (defun mixi-topic-comment-list-page (topic) (concat "/view_bbs.pl?page=all" @@ -2301,7 +2301,8 @@ Increase this value when unexpected error frequently occurs." ;; FIXME: Split regexp to time, owner(id and nick) and contents. (defconst mixi-topic-comment-list-regexp - "\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\) + "
\\(\\|\\) +\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\)
\\(.*\\)
@@ -2316,7 +2317,8 @@ Increase this value when unexpected error frequently occurs." ;; FIXME: Split regexp to time, owner(id and nick) and contents. (defconst mixi-event-comment-list-regexp - "\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\) + "
\\(\\|\\) +\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\)
\\(.*\\)
@@ -2340,25 +2342,27 @@ Increase this value when unexpected error frequently occurs." (setq page nil)) (let ((items (mixi-get-matched-items page regexp range t))) (mapcar (lambda (item) - (let (owner-id owner-nick year month day hour minute content) + (let (owner-id owner-nick year month day hour minute content + count) (if (eq (mixi-object-class parent) 'mixi-diary) (progn (setq owner-id (nth 1 item)) (setq owner-nick (nth 2 item)) - (setq year (nth 3 item)) - (setq month (nth 4 item)) - (setq day (nth 5 item)) - (setq hour (nth 6 item)) - (setq minute (nth 7 item)) - (setq content (nth 8 item))) - (setq owner-id (nth 5 item)) - (setq owner-nick (nth 6 item)) - (setq year (nth 0 item)) - (setq month (nth 1 item)) - (setq day (nth 2 item)) - (setq hour (nth 3 item)) - (setq minute (nth 4 item)) - (setq content (nth 7 item))) + (setq year (nth 4 item)) + (setq month (nth 5 item)) + (setq day (nth 6 item)) + (setq hour (nth 7 item)) + (setq minute (nth 8 item)) + (setq content (nth 9 item))) + (setq owner-id (nth 8 item)) + (setq owner-nick (nth 9 item)) + (setq year (nth 3 item)) + (setq month (nth 4 item)) + (setq day (nth 5 item)) + (setq hour (nth 6 item)) + (setq minute (nth 7 item)) + (setq content (nth 10 item)) + (setq count (nth 1 item))) (mixi-make-comment parent (mixi-make-friend owner-id owner-nick) (encode-time @@ -2368,7 +2372,7 @@ Increase this value when unexpected error frequently occurs." (string-to-number day) (string-to-number month) (string-to-number year)) - content))) + content count))) items)))) (defmacro mixi-new-comment-list-page () @@ -2396,6 +2400,40 @@ Increase this value when unexpected error frequently occurs." diary))) items)))) +(defmacro mixi-new-bbs-comment-list-page () + `(concat "/new_bbs_comment.pl?page=%d")) + +(defconst mixi-new-bbs-comment-list-regexp + "") + +;;;###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)))