X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=mixi.el;h=7efaeddff8bd6dd2d4192b22dfc011a1a85df8a1;hb=HEAD;hp=2c2f8622133bd463b7e61f8dc5377d02a0a7b009;hpb=62976ecf8c68b96ea3ba21bcd0d207fc4c4e25de;p=elisp%2Fmixi.git
diff --git a/mixi.el b/mixi.el
index 2c2f862..7efaedd 100644
--- a/mixi.el
+++ b/mixi.el
@@ -1,6 +1,6 @@
-;; mixi.el --- API libraries for accessing to mixi
+;; mixi.el --- API libraries for accessing to mixi -*- coding: euc-jp -*-
-;; Copyright (C) 2005,2006 OHASHI Akira
+;; Copyright (C) 2005, 2006, 2007, 2008, 2009 OHASHI Akira
;; Author: OHASHI Akira
;; Keywords: hypermedia
@@ -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:
@@ -29,19 +29,26 @@
;; * mixi-get-friends
;; * mixi-get-favorites
;; * mixi-get-logs
+;; * mixi-get-self-logs
+;; * mixi-get-recommended-friends (indies)
;; * mixi-get-diaries
;; * mixi-get-new-diaries
;; * mixi-search-diaries
;; * mixi-get-communities
;; * mixi-search-communities
+;; * mixi-get-recommended-communities (indies)
;; * mixi-get-bbses
;; * mixi-get-new-bbses
;; * 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
+;; * mixi-get-releases
+;; * mixi-get-echoes (limited)
+;; * mixi-get-new-echoes (limited)
;;
;; APIs for posting:
;;
@@ -49,10 +56,11 @@
;; * mixi-post-topic
;; * mixi-post-comment
;; * mixi-post-message
+;; * mixi-post-echo (limited)
;;
;; Utilities:
;;
-;; * mixi-remove-markup
+;; * mixi-remove-markup (half broken)
;; Examples:
;;
@@ -62,16 +70,18 @@
;; (buffer (get-buffer-create "*temp*"))
;; (format "%Y/%m/%d %H:%M"))
;; (pop-to-buffer buffer)
-;; (mapc (lambda (diary)
-;; (let ((subject (mixi-diary-title diary))
-;; (from (mixi-friend-nick (mixi-diary-owner diary)))
-;; (date (format-time-string format (mixi-diary-time diary)))
-;; (body (mixi-remove-markup (mixi-diary-content diary))))
-;; (insert "From: " from "\n"
-;; "Subject: " subject "\n"
-;; "Date: " date "\n\n"
-;; body "\n\n")))
-;; (mixi-get-new-diaries range))
+;; (let ((diaries (mixi-get-new-diaries range)))
+;; (while diaries
+;; (let* ((diary (car diaries))
+;; (subject (mixi-diary-title diary))
+;; (from (mixi-friend-nick (mixi-diary-owner diary)))
+;; (date (format-time-string format (mixi-diary-time diary)))
+;; (body (mixi-remove-markup (mixi-diary-content diary))))
+;; (insert "From: " from "\n"
+;; "Subject: " subject "\n"
+;; "Date: " date "\n\n"
+;; body "\n\n"))
+;; (setq diaries (cdr diaries))))
;; (set-buffer-modified-p nil)
;; (setq buffer-read-only t)
;; (goto-char (point-min)))
@@ -83,29 +93,31 @@
;; (buffer (get-buffer-create "*temp*"))
;; (format "%Y/%m/%d %H:%M"))
;; (pop-to-buffer buffer)
-;; (mapc (lambda (diary)
-;; (let ((subject (mixi-diary-title diary))
-;; (from (mixi-friend-nick (mixi-diary-owner diary)))
-;; (date (format-time-string format (mixi-diary-time diary)))
-;; (body (mixi-remove-markup (mixi-diary-content diary))))
-;; (insert "From: " from "\n"
-;; "Subject: " subject "\n"
-;; "Date: " date "\n\n"
-;; body "\n\n")
-;; (mapc (lambda (comment)
-;; (let ((from (mixi-friend-nick
-;; (mixi-comment-owner comment)))
-;; (subject (concat "Re: " subject))
-;; (date (format-time-string
-;; format (mixi-comment-time comment)))
-;; (body (mixi-remove-markup
-;; (mixi-comment-content comment))))
-;; (insert "From: " from "\n"
-;; "Subject: " subject "\n"
-;; "Date: " date "\n\n"
-;; body "\n\n")))
-;; (mixi-get-comments diary range))))
-;; (mixi-get-new-diaries range))
+;; (let ((diaries (mixi-get-new-diaries range)))
+;; (while diaries
+;; (let* ((diary (car diaries))
+;; (subject (mixi-diary-title diary))
+;; (from (mixi-friend-nick (mixi-diary-owner diary)))
+;; (date (format-time-string format (mixi-diary-time diary)))
+;; (body (mixi-remove-markup (mixi-diary-content diary))))
+;; (insert "From: " from "\n"
+;; "Subject: " subject "\n"
+;; "Date: " date "\n\n"
+;; body "\n\n")
+;; (let ((comments (mixi-get-comments diary range)))
+;; (while comments
+;; (let* ((comment (car comments))
+;; (from (mixi-friend-nick (mixi-comment-owner comment)))
+;; (subject (concat "Re: " subject))
+;; (date (format-time-string format
+;; (mixi-comment-time comment)))
+;; (body (mixi-remove-markup (mixi-comment-content comment))))
+;; (insert "From: " from "\n"
+;; "Subject: " subject "\n"
+;; "Date: " date "\n\n"
+;; body "\n\n"))
+;; (setq comments (cdr comments)))))
+;; (setq diaries (cdr diaries))))
;; (set-buffer-modified-p nil)
;; (setq buffer-read-only t)
;; (goto-char (point-min)))
@@ -123,13 +135,12 @@
;; at run-time.
(eval-when-compile
(defvar w3m-use-cookies)
- (defvar url-request-method)
- (defvar url-request-data)
- (defvar url-request-extra-headers)
(autoload 'w3m-decode-buffer "w3m")
(autoload 'w3m-retrieve "w3m")
(autoload 'url-retrieve-synchronously "url"))
+(defconst mixi-revision "$Revision: 1.210 $")
+
(defgroup mixi nil
"API library for accessing to mixi."
:group 'hypermedia)
@@ -211,6 +222,11 @@ Increase this value when unexpected error frequently occurs."
:type 'number
:group 'mixi)
+(defcustom mixi-replace-tab-and-space-to-nbsp t
+ "*If non-nil, replace tab and space to for keeping formatted."
+ :type 'boolean
+ :group 'mixi)
+
(defcustom mixi-cache-expires nil
"*Seconds for expiration of a cached object."
:type '(radio (integer :tag "Expired seconds")
@@ -262,9 +278,7 @@ Increase this value when unexpected error frequently occurs."
¿·¤ÏÀ©¸Â¤µ¤»¤Æ¤¤¤¿¤À¤¤¤Æ¤ª¤ê¤Þ¤¹¡£¤´ÌÂÏǤò¤ª¤«¤±¤¤¤¿¤·¤Þ¤¹¤¬¡¢¤·¤Ð¤é¤¯¤ª
ÂÔ¤Á¤¤¤¿¤À¤¤¤Æ¤«¤éÁàºî¤ò¤ª¤³¤Ê¤Ã¤Æ¤¯¤À¤µ¤¤¡£")
(defconst mixi-warning-continuously-accessing
- "´Ö³Ö¤ò¶õ¤±¤Ê¤¤Ï¢Â³Åª¤Ê¥Ú¡¼¥¸¤ÎÁ«°Ü¡¦¹¹¿·¤òÉÑÈˤˤª¤³¤Ê¤ï¤ì¤Æ¤¤¤ë¤³¤È¤¬¸«
-¼õ¤±¤é¤ì¤Þ¤·¤¿¤Î¤Ç¡¢°ì»þŪ¤ËÁàºî¤òÄä»ß¤µ¤»¤Æ¤¤¤¿¤À¤¤Þ¤¹¡£¿½¤·Ìõ¤´¤¶¤¤¤Þ
-¤»¤ó¤¬¡¢¤·¤Ð¤é¤¯¤Î´Ö¤ªÂÔ¤Á¤¯¤À¤µ¤¤¡£")
+ "´Ö³Ö¤ò¶õ¤±¤Ê¤¤Ï¢Â³Åª¤Ê¥Ú¡¼¥¸¤ÎÁ«°Ü¡¦¹¹¿·¤òÉÑÈˤˤª¤³¤Ê¤ï¤ì¤Æ¤¤¤ë¤³¤È¤¬¸«¼õ¤±¤é¤ì¤Þ¤·¤¿¤Î¤Ç¡¢°ì»þŪ¤ËÁàºî¤òÄä»ß¤µ¤»¤Æ¤¤¤¿¤À¤¤Þ¤¹¡£¿½¤·Ìõ¤´¤¶¤¤¤Þ¤»¤ó¤¬¡¢¤·¤Ð¤é¤¯¤Î´Ö¤ªÂÔ¤Á¤¯¤À¤µ¤¤¡£")
(defmacro mixi-retrieve (url &optional post-data)
`(funcall (intern (concat "mixi-" (symbol-name mixi-backend) "-retrieve"))
@@ -315,16 +329,17 @@ Increase this value when unexpected error frequently occurs."
(url-request-data post-data)
(url-request-extra-headers extra-headers)
(url (mixi-expand-url url))
+ url-show-status
(buffer (url-retrieve-synchronously url))
ret)
(unless (bufferp buffer)
- (error (mixi-message "Cannot retrieve")))
+ (error (mixi-message "Cannot retrieve: " url)))
(with-current-buffer buffer
(goto-char (point-min))
(while (looking-at "HTTP/[0-9]+\\.[0-9]+ [13][0-9][0-9]")
(delete-region (point) (re-search-forward "\r?\n\r?\n")))
(unless (looking-at "HTTP/[0-9]+\\.[0-9]+ 200")
- (error (mixi-message "Cannot retrieve")))
+ (error (mixi-message "Cannot retrieve: " url)))
(delete-region (point) (re-search-forward "\r?\n\r?\n"))
(setq ret (decode-coding-string (buffer-string) mixi-coding-system))
(kill-buffer buffer)
@@ -340,7 +355,7 @@ Increase this value when unexpected error frequently occurs."
(let ((url (mixi-expand-url url)))
(with-temp-buffer
(if (not (string= (w3m-retrieve url nil nil post-data) "text/html"))
- (error (mixi-message "Cannot retrieve"))
+ (error (mixi-message "Cannot retrieve: " url))
(w3m-decode-buffer url)
(let ((ret (buffer-substring-no-properties (point-min) (point-max))))
(mixi-parse-buffer url ret post-data))))))
@@ -381,7 +396,7 @@ Increase this value when unexpected error frequently occurs."
(while (looking-at "HTTP/[0-9]+\\.[0-9]+ [13][0-9][0-9]")
(delete-region (point) (re-search-forward "\r?\n\r?\n")))
(unless (looking-at "HTTP/[0-9]+\\.[0-9]+ 200")
- (error (mixi-message "Cannot retrieve")))
+ (error (mixi-message "Cannot retrieve: " url)))
(delete-region (point) (re-search-forward "\r?\n\r?\n"))
(setq ret (decode-coding-string (buffer-string) mixi-coding-system))
(mixi-parse-buffer url ret post-data))))
@@ -398,7 +413,7 @@ Increase this value when unexpected error frequently occurs."
(mixi-curl-retrieve url nil (reverse form-data))))
(defconst mixi-my-id-regexp
- "")
+
(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
- "
")
(defconst mixi-friend-list-nick-regexp
- "\\(.+\\)¤µ¤ó([0-9]+) ")
+ "\\(.+\\)¤µ¤ó([0-9]+) ")
+;;;###autoload
(defun mixi-get-friends (&rest friend-or-range)
"Get friends of FRIEND."
(when (> (length friend-or-range) 2)
@@ -1040,45 +1098,43 @@ Increase this value when unexpected error frequently occurs."
(setq range (nth 0 friend-or-range)))
(unless (or (null friend) (mixi-friend-p friend))
(signal 'wrong-type-argument (list 'mixi-friend-p friend)))
- (let ((ids (mixi-get-matched-items (mixi-friend-list-page friend)
- mixi-friend-list-id-regexp
- range))
- (nicks (mixi-get-matched-items (mixi-friend-list-page friend)
- mixi-friend-list-nick-regexp
- range)))
- (let ((index 0)
- ret)
- (while (< index (length ids))
- (setq ret (cons (mixi-make-friend (nth 0 (nth index ids))
- (nth 0 (nth index nicks))) ret))
- (incf index))
- (reverse ret)))))
+ (let (list-page list-nick-regexp)
+ (if (or (null friend) (equal friend mixi-me))
+ (setq list-page 'mixi-my-friend-list-page
+ list-nick-regexp mixi-my-friend-list-nick-regexp)
+ (setq list-page 'mixi-friend-list-page
+ list-nick-regexp mixi-friend-list-nick-regexp))
+ (let ((ids (mixi-get-matched-items (funcall list-page friend)
+ mixi-friend-list-id-regexp
+ range))
+ (nicks (mixi-get-matched-items (funcall list-page friend)
+ list-nick-regexp
+ range)))
+ (let ((index 0)
+ ret)
+ (while (< index (length ids))
+ (setq ret (cons (mixi-make-friend (nth 0 (nth index ids))
+ (nth 0 (nth index nicks))) ret))
+ (incf index))
+ (reverse ret))))))
;; Favorite.
(defmacro mixi-favorite-list-page ()
`(concat "/list_bookmark.pl?page=%d"))
-(defconst mixi-favorite-list-id-regexp
- " ")
-(defconst mixi-favorite-list-nick-regexp
- " ̾ Á°
-\\(.+\\) ")
+(defconst mixi-favorite-list-regexp
+ "̾Á°
+\\(.*\\) ")
+;;;###autoload
(defun mixi-get-favorites (&optional range)
"Get favorites."
- (let ((ids (mixi-get-matched-items (mixi-favorite-list-page)
- mixi-favorite-list-id-regexp
- range))
- (nicks (mixi-get-matched-items (mixi-favorite-list-page)
- mixi-favorite-list-nick-regexp
+ (let ((items (mixi-get-matched-items (mixi-favorite-list-page)
+ mixi-favorite-list-regexp
range)))
- (let ((index 0)
- ret)
- (while (< index (length ids))
- (setq ret (cons (mixi-make-friend (nth 0 (nth index ids))
- (nth 0 (nth index nicks))) ret))
- (incf index))
- (reverse ret))))
+ (mapcar (lambda (item)
+ (mixi-make-friend (nth 0 item) (nth 1 item)))
+ items)))
;; Log object.
(defun mixi-make-log (friend time)
@@ -1100,25 +1156,57 @@ Increase this value when unexpected error frequently occurs."
(signal 'wrong-type-argument (list 'mixi-log-p log)))
(aref (cdr log) 1))
-(defmacro mixi-log-list-page ()
- `(concat "/show_log.pl"))
+(defconst mixi-log-list-page "/show_log.pl")
(defconst mixi-log-list-regexp
- "\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\) \\(.*\\) ")
+ "\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\)\\(.*?\\) ")
+
+(defun mixi-get-logs-internal (list-page &optional range)
+ (let ((items (mixi-get-matched-items list-page
+ mixi-log-list-regexp
+ range))
+ (year (nth 5 (decode-time (current-time))))
+ (month (nth 4 (decode-time (current-time)))))
+ (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-log (mixi-make-friend (nth 4 item) (nth 5 item))
+ (encode-time 0
+ (string-to-number (nth 3 item))
+ (string-to-number (nth 2 item))
+ (string-to-number (nth 1 item))
+ month year))))
+ items)))
+;;;###autoload
(defun mixi-get-logs (&optional range)
"Get logs."
- (let ((items (mixi-get-matched-items (mixi-log-list-page)
- mixi-log-list-regexp
+ (mixi-get-logs-internal mixi-log-list-page range))
+
+(defconst mixi-log-self-list-page "/show_self_log.pl")
+
+;;;###autoload
+(defun mixi-get-self-logs (&optional range)
+ "Get self logs."
+ (mixi-get-logs-internal mixi-log-self-list-page range))
+
+;; Recommended friend.
+(defmacro mixi-recommended-friend-list-page ()
+ `(concat "http://indies.mixi.jp/recommend.pl"))
+
+(defconst mixi-recommended-friend-list-regexp
+ "\\(.+?\\)¤µ¤ó([0-9]+) ")
+
+;;;###autoload
+(defun mixi-get-recommended-friends (&optional range)
+ "Get recommended friends."
+ (let ((items (mixi-get-matched-items (mixi-recommended-friend-list-page)
+ mixi-recommended-friend-list-regexp
range)))
(mapcar (lambda (item)
- (mixi-make-log (mixi-make-friend (nth 5 item) (nth 6 item))
- (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)))))
+ (mixi-make-friend (nth 0 item) (nth 1 item)))
items)))
;; Diary object.
@@ -1150,39 +1238,46 @@ Increase this value when unexpected error frequently occurs."
"&owner_id=" (mixi-friend-id (mixi-diary-owner ,diary))))
(defconst mixi-diary-closed-regexp
- "ͧ¿Í\\(¤Îͧ¿Í\\)?¤Þ¤Ç¸ø³«¤Î¤¿¤áÆɤळ¤È¤¬½ÐÍè¤Þ¤»¤ó¡£ ")
+ "¤³¤ÎÆüµ¤Ë¥¢¥¯¥»¥¹¤Ç¤¤Þ¤»¤ó¡£°Ê²¼¤Î²ÄǽÀ¤¬¹Í¤¨¤é¤ì¤Þ¤¹¡£ ")
(defconst mixi-diary-owner-nick-regexp
- "\\(.+?\\)\\(¤µ¤ó\\)?¤ÎÆüµ ")
-(defconst mixi-diary-time-regexp
- "\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü\\( \\| \\)\\([0-9]+\\):\\([0-9]+\\) ")
+ "
+
\\(.+?\\)\\(¤µ¤ó\\)?¤ÎÆüµ ")
(defconst mixi-diary-title-regexp
- "
\\([^<]+\\) ")
+ "
+
+\\([^<\n]+\\)\\(\\)?")
+(defconst mixi-diary-time-regexp
+ "\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü\\([0-9]+\\):\\([0-9]+\\) ")
(defconst mixi-diary-content-regexp
- " \\(.*\\) ")
+ "
+\\(\\(.\\|\r?\n\\)*?\\)
+
")
(defun mixi-realize-diary (diary &optional page)
"Realize a DIARY."
- ;; FIXME: Check a expiration of cache?
+ ;; FIXME: Check an expiration of cache?
(unless (mixi-object-realized-p diary)
(with-mixi-retrieve (or page (mixi-diary-page diary))
- (unless (re-search-forward mixi-diary-closed-regexp nil t)
- (if (re-search-forward mixi-diary-owner-nick-regexp nil t)
- (mixi-friend-set-nick (mixi-diary-owner diary) (match-string 1))
- (mixi-realization-error 'cannot-find-owner-nick diary))
- (if (re-search-forward mixi-diary-time-regexp nil t)
- (mixi-diary-set-time
- diary (encode-time 0 (string-to-number (match-string 10))
- (string-to-number (match-string 9))
- (string-to-number (match-string 7))
- (string-to-number (match-string 6))
- (string-to-number (match-string 5))))
- (mixi-realization-error 'cannot-find-time diary))
- (if (re-search-forward mixi-diary-title-regexp nil t)
- (mixi-diary-set-title diary (match-string 2))
- (mixi-realization-error 'cannot-find-title diary))
- (if (re-search-forward mixi-diary-content-regexp nil t)
- (mixi-diary-set-content diary (match-string 2))
- (mixi-realization-error 'cannot-find-content diary))))
+ (let ((case-fold-search t))
+ (unless (re-search-forward mixi-diary-closed-regexp nil t)
+ (if (re-search-forward mixi-diary-owner-nick-regexp nil t)
+ (mixi-friend-set-nick (mixi-diary-owner diary)
+ (match-string 2))
+ (mixi-realization-error 'cannot-find-owner-nick diary))
+ (if (re-search-forward mixi-diary-title-regexp nil t)
+ (mixi-diary-set-title diary (match-string 1))
+ (mixi-realization-error 'cannot-find-title diary))
+ (if (re-search-forward mixi-diary-time-regexp nil t)
+ (mixi-diary-set-time
+ diary (encode-time 0 (string-to-number (match-string 5))
+ (string-to-number (match-string 4))
+ (string-to-number (match-string 3))
+ (string-to-number (match-string 2))
+ (string-to-number (match-string 1))))
+ (mixi-realization-error 'cannot-find-time diary))
+ (if (re-search-forward mixi-diary-content-regexp nil t)
+ (mixi-diary-set-content diary (match-string 1))
+ (mixi-realization-error 'cannot-find-content diary)))))
(mixi-object-touch diary)))
(defun mixi-diary-owner (diary)
@@ -1255,10 +1350,11 @@ Increase this value when unexpected error frequently occurs."
(when ,friend (concat "&id=" (mixi-friend-id ,friend)))))
(defconst mixi-diary-list-regexp
- "
-\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\) \\( \\|\\)
- \\(.*\\) ")
+ "\\( \\|\\)\\(.*\\) \\(ÊÔ½¸¤¹¤ë \\|\\).*
+\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü\n?\\([0-9]+\\):\\([0-9]+\\)
+")
+;;;###autoload
(defun mixi-get-diaries (&rest friend-or-range)
"Get diaries of FRIEND."
(when (> (length friend-or-range) 2)
@@ -1273,74 +1369,75 @@ Increase this value when unexpected error frequently occurs."
(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 1 item) nil
+ (encode-time
+ 0 (string-to-number (nth 8 item))
+ (string-to-number (nth 7 item))
+ (string-to-number (nth 6 item))
+ (string-to-number (nth 5 item))
+ (string-to-number (nth 4 item)))
+ (nth 2 item)))
items))))
(defmacro mixi-new-diary-list-page ()
`(concat "/new_friend_diary.pl?page=%d"))
(defconst mixi-new-diary-list-regexp
- " \\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\)
-\\(.+\\) (\\(.*\\)) ")
+ "\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\)
+\\(.+\\) (\\(.*\\))̾ Á°
-\\(.*\\)
-
-
-
-
-¥¿¥¤¥È¥ë
-\\(.+\\)
-
-
-ËÜ Ê¸
-\\(.*\\)
-
-
-
-ºîÀ®Æü»þ
-\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\)
-
-
-")
-
+ "
+
+
+
\\(.+\\) \\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\)
+
\\(.*\\)
+
+ ")
+
+;;;###autoload
(defun mixi-search-diaries (keyword &optional range)
(let ((items (mixi-get-matched-items (mixi-search-diary-list-page keyword)
mixi-search-diary-list-regexp
@@ -1348,31 +1445,32 @@ Increase this value when unexpected error frequently occurs."
(year (nth 5 (decode-time (current-time))))
(month (nth 4 (decode-time (current-time)))))
(mapcar (lambda (item)
- (let ((month-of-item (string-to-number (nth 3 item))))
+ (let ((month-of-item (string-to-number (nth 4 item))))
(when (> month-of-item month)
(decf year))
(setq month month-of-item)
- (mixi-make-diary (mixi-make-friend (nth 8 item) (nth 0 item))
- (nth 7 item)
+ (mixi-make-diary (mixi-make-friend (nth 1 item) (nth 2 item))
+ (nth 0 item)
nil
(encode-time
- 0 (string-to-number (nth 6 item))
+ 0 (string-to-number (nth 7 item))
+ (string-to-number (nth 6 item))
(string-to-number (nth 5 item))
- (string-to-number (nth 4 item))
month year)
- (nth 1 item)
- (nth 2 item))))
+ (nth 3 item)
+ (nth 8 item))))
items)))
(defmacro mixi-post-diary-page ()
`(concat "/add_diary.pl"))
(defconst mixi-post-key-regexp
- " ")
+ " \\(ºîÀ®\\|½ñ¤¹þ¤ß\\)¤¬´°Î»¤·¤Þ¤·¤¿¡£È¿±Ç¤Ë»þ´Ö¤¬¤«¤«¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¤Î¤Ç¡¢É½¼¨¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¾¯¡¹¤ªÂÔ¤Á¤¯¤À¤µ¤¤¡£")
+ "\\(ºîÀ®\\|½ñ¤¹þ¤ß\\)¤¬´°Î»¤·¤Þ¤·¤¿¡£È¿±Ç¤Ë»þ´Ö¤¬¤«¤«¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£
")
;; FIXME: Support photos.
+;;;###autoload
(defun mixi-post-diary (title content)
"Post a diary."
(unless (stringp title)
@@ -1391,7 +1489,8 @@ Increase this value when unexpected error frequently occurs."
(setq fields `(("post_key" . ,post-key)
("id" . ,(mixi-friend-id (mixi-make-me)))
("diary_title" . ,title)
- ("diary_body" . ,content)
+ ("diary_body" . ,(mixi-replace-tab-and-space-to-nbsp
+ content))
("submit" . "confirm")))
(with-mixi-post-form (mixi-post-diary-page) fields
(unless (re-search-forward mixi-post-succeed-regexp nil t)
@@ -1427,71 +1526,78 @@ Increase this value when unexpected error frequently occurs."
(defconst mixi-community-nodata-regexp
"^¥Ç¡¼¥¿¤¬¤¢¤ê¤Þ¤»¤ó")
(defconst mixi-community-name-regexp
- "\\(.*\\) ")
+ "
+
\\(.*\\) ")
(defconst mixi-community-birthday-regexp
- "
³«ÀßÆü
-
\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü")
+ "³«ÀßÆü
+\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü ")
;; FIXME: Care when the owner has seceded.
(defconst mixi-community-owner-regexp
- "´ÉÍý¿Í
-
-
+ "´ÉÍý¿Í
+
\\(.*\\) ")
(defconst mixi-community-category-regexp
- "¥«¥Æ¥´¥ê
-\\([^<]+\\) ")
+ " ¥«¥Æ¥´¥ê
+\\(.+\\) ")
(defconst mixi-community-members-regexp
- " ¥á¥ó¥Ð¡¼¿ô
-\\([0-9]+\\)¿Í ")
+ "¥á¥ó¥Ð¡¼¿ô
+\\([0-9]+\\)¿Í ")
(defconst mixi-community-open-level-regexp
- "»²²Ã¾ò·ï¤È ¸ø³«¥ì¥Ù¥ë
-\\(.+\\) ")
+ "»²²Ã¾ò·ï¤È ¸ø³«¥ì¥Ù¥ë
+\\(.+\\) ")
(defconst mixi-community-authority-regexp
- "¥È¥Ô¥Ã¥¯ºîÀ®¤Î¸¢¸Â
-\\(.+\\) ")
+ "¥È¥Ô¥Ã¥¯¤Î ºîÀ®¸¢¸Â
+
+\\(.+\\)
+
+
+ ")
(defconst mixi-community-description-regexp
- "\\(.+\\) ")
+ "
+
+
+
+")
+
+;;;###autoload
+(defun mixi-get-releases (&optional range)
+ "Get releases."
+ (let ((items (mixi-get-matched-items (mixi-release-list-page)
+ mixi-release-list-regexp
+ range)))
+ (mapcar (lambda (item)
+ (mixi-make-release (nth 0 item)
+ (encode-time 0 0 0
+ (string-to-number (nth 3 item))
+ (string-to-number (nth 2 item))
+ (string-to-number (nth 1 item)))
+ (nth 4 item)))
+ items)))
+
+;; Echo object.
+(defvar mixi-echo-cache (make-hash-table :test 'equal))
+;; FIXME: Support parent.
+(defun mixi-make-echo (owner post-time &optional content)
+ "Return an echo object."
+ (let ((owner (or owner (mixi-make-me))))
+ (mixi-make-cache (list (mixi-friend-id owner) post-time)
+ (cons 'mixi-echo (vector nil owner post-time content))
+ mixi-echo-cache)))
+
+(defconst mixi-echo-url-regexp
+ "view_echo\\.pl\\?id=\\([0-9]+\\)&post_time=\\([0-9]+\\)")
+
+(defun mixi-make-echo-from-url (url)
+ "Return an echo object from URL."
+ (when (string-match mixi-echo-url-regexp url)
+ (let ((owner-id (match-string 1 url))
+ (post-time (match-string 2 url)))
+ (mixi-make-echo (mixi-make-friend owner-id) post-time))))
+
+(defmacro mixi-echo-p (echo)
+ `(eq (mixi-object-class ,echo) 'mixi-echo))
+
+(defmacro mixi-echo-page (echo)
+ `(concat "/view_echo.pl?id=" (mixi-friend-id (mixi-echo-owner ,echo))
+ "&post_time=" (mixi-echo-post-time ,echo)))
+
+(defconst mixi-echo-owner-nick-regexp
+ "\\(.*\\)
")
+(defconst mixi-echo-content-regexp
+ "\\(.+\\)
")
+
+(defun mixi-realize-echo (echo)
+ "Realize an ECHO."
+ ;; FIXME: Check an expiration of cache?
+ (unless (mixi-object-realized-p echo)
+ (with-mixi-retrieve (mixi-echo-page echo)
+ (let ((case-fold-search t))
+ (if (re-search-forward mixi-echo-owner-nick-regexp nil t)
+ (mixi-friend-set-nick (mixi-echo-owner echo)
+ (match-string 1))
+ (mixi-realization-error 'cannot-find-owner-nick echo))
+ (if (re-search-forward mixi-echo-content-regexp nil t)
+ (mixi-echo-set-content echo (match-string 1))
+ (mixi-realization-error 'cannot-find-owner-nick echo))))
+ (mixi-object-touch echo)))
+
+(defun mixi-echo-owner (echo)
+ "Return the owner of ECHO."
+ (unless (mixi-echo-p echo)
+ (signal 'wrong-type-argument (list 'mixi-echo-p echo)))
+ (aref (cdr echo) 1))
+
+(defun mixi-echo-post-time (echo)
+ "Return the post-time of ECHO."
+ (unless (mixi-echo-p echo)
+ (signal 'wrong-type-argument (list 'mixi-echo-p echo)))
+ (aref (cdr echo) 2))
+
+(defun mixi-echo-content (echo)
+ "Return the content of ECHO."
+ (unless (mixi-echo-p echo)
+ (signal 'wrong-type-argument (list 'mixi-echo-p echo)))
+ (mixi-realize-echo echo)
+ (aref (cdr echo) 3))
+
+(defun mixi-echo-set-content (echo content)
+ "Set the content of ECHO."
+ (unless (mixi-echo-p echo)
+ (signal 'wrong-type-argument (list 'mixi-echo-p echo)))
+ (aset (cdr echo) 3 content))
+
+(defmacro mixi-echo-list-page (&optional friend)
+ `(concat "/list_echo.pl?page=%d"
+ (when ,friend (concat "&id=" (mixi-friend-id ,friend)))))
+
+(defconst mixi-echo-list-regexp
+ "")
+
+;;;###autoload
+(defun mixi-get-echoes (&rest friend-or-range)
+ "Get echoes of FRIEND."
+ (when (> (length friend-or-range) 2)
+ (signal 'wrong-number-of-arguments
+ (list 'mixi-get-echoes (length friend-or-range))))
+ (let ((friend (nth 0 friend-or-range))
+ (range (nth 1 friend-or-range)))
+ (when (or (not (mixi-friend-p friend)) (mixi-friend-p range))
+ (setq friend (nth 1 friend-or-range))
+ (setq range (nth 0 friend-or-range)))
+ (unless (or (null friend) (mixi-friend-p friend))
+ (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+ (let ((items (mixi-get-matched-items (mixi-echo-list-page friend)
+ mixi-echo-list-regexp
+ range)))
+ (mapcar (lambda (item)
+ (mixi-make-echo friend (nth 1 item)))
+ items))))
+
+(defmacro mixi-new-echo-list-page ()
+ `(concat "/recent_echo.pl?page=%d"))
+
+(defconst mixi-new-echo-list-regexp
+ " ")
+
+;;;###autoload
+(defun mixi-get-new-echoes (&optional range)
+ "Get new echoes."
+ (let ((items (mixi-get-matched-items (mixi-new-echo-list-page)
+ mixi-new-echo-list-regexp
+ range)))
+ (mapcar (lambda (item)
+ (mixi-make-echo (mixi-make-friend (nth 0 item)) (nth 1 item)))
+ items)))
+
+(defmacro mixi-post-echo-page ()
+ `(concat "/add_echo.pl"))
+
+(defconst mixi-echo-post-succeed-regexp mixi-my-id-regexp)
+
+;;;###autoload
+(defun mixi-post-echo (content &optional parent)
+ "Post an echo."
+ (unless (stringp content)
+ (signal 'wrong-type-argument (list 'stringp content)))
+ (unless (or (null parent) (mixi-echo-p parent))
+ (signal 'wrong-type-argument (list 'mixi-echo-p parent)))
+ (let (fields post-key)
+ (with-mixi-retrieve (format (mixi-new-echo-list-page) 1)
+ (if (re-search-forward mixi-post-key-regexp nil t)
+ (setq post-key (match-string 1))
+ (mixi-post-error 'cannot-find-key)))
+ (setq fields `(("post_key" . ,post-key)
+ ("redirect" . "home")
+ ("body" . ,content)))
+ (when (mixi-echo-p parent)
+ (setq fields (cons `("parent_member_id" . ,(mixi-friend-id
+ (mixi-echo-owner parent)))
+ fields))
+ (setq fields (cons `("parent_post_time" . ,(mixi-echo-post-time parent))
+ fields)))
+ (with-mixi-post-form (mixi-post-echo-page) fields
+ (unless (re-search-forward mixi-echo-post-succeed-regexp nil t)
+ (mixi-post-error 'cannot-find-succeed)))))
+
(provide 'mixi)
;;; mixi.el ends here