X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=mixi.el;h=171c070173cdb45cbbed9c880f8ee679c05dd705;hb=ac17113829f33b0afa7bb9976df17190ef7fe040;hp=4d9566ad61026a0048f1c4d7dd59d989d98372c6;hpb=23a313499c07a1266f88265641befe28b836f9d2;p=elisp%2Fmixi.git
diff --git a/mixi.el b/mixi.el
index 4d9566a..171c070 100644
--- a/mixi.el
+++ b/mixi.el
@@ -1,6 +1,6 @@
;; mixi.el --- API libraries for accessing to mixi -*- coding: euc-jp -*-
-;; Copyright (C) 2005, 2006, 2007, 2008 OHASHI Akira
+;; Copyright (C) 2005, 2006, 2007, 2008, 2009 OHASHI Akira
;; Author: OHASHI Akira
;; Keywords: hypermedia
@@ -29,6 +29,7 @@
;; * 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
@@ -47,6 +48,7 @@
;; * mixi-get-news
;; * mixi-get-releases
;; * mixi-get-echoes (limited)
+;; * mixi-get-new-echoes (limited)
;;
;; APIs for posting:
;;
@@ -133,15 +135,11 @@
;; at run-time.
(eval-when-compile
(defvar w3m-use-cookies)
- (defvar url-request-method)
- (defvar url-request-data)
- (defvar url-request-extra-headers)
- (defvar url-show-status)
(autoload 'w3m-decode-buffer "w3m")
(autoload 'w3m-retrieve "w3m")
(autoload 'url-retrieve-synchronously "url"))
-(defconst mixi-revision "$Revision: 1.190 $")
+(defconst mixi-revision "$Revision: 1.205 $")
(defgroup mixi nil
"API library for accessing to mixi."
@@ -224,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")
@@ -275,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"))
@@ -570,6 +571,18 @@ Increase this value when unexpected error frequently occurs."
(setq pos (+ (match-end 0) 1)))
string))
+(defun mixi-replace-tab-and-space-to-nbsp (string)
+ (when mixi-replace-tab-and-space-to-nbsp
+ (let ((pos 0))
+ (while (or (string-match "\t" string pos)
+ (string-match " " string pos))
+ (if (string= (match-string 0 string) "\t")
+ (setq string (replace-match (make-string tab-width ?\ )
+ nil nil string))
+ (setq string (replace-match " " nil nil string))
+ (setq pos (+ (match-end 0) 1))))
+ string)))
+
;; Object.
(defconst mixi-object-prefix "mixi-")
@@ -1057,12 +1070,16 @@ Increase this value when unexpected error frequently occurs."
(signal 'wrong-type-argument (list 'mixi-friend-p friend)))
(aset (cdr friend) 13 profile))
-(defmacro mixi-friend-list-page (&optional friend)
- `(concat "/list_friend.pl?page=%d"
- (when ,friend (concat "&id=" (mixi-friend-id ,friend)))))
+(defun mixi-my-friend-list-page (&optional dummy)
+ (concat "/list_friend_simple.pl?page=%d"))
+
+(defun mixi-friend-list-page (friend)
+ (concat "/list_friend.pl?page=%d&id=" (mixi-friend-id friend)))
(defconst mixi-friend-list-id-regexp
"\\(.+\\)([0-9]+)
")
(defconst mixi-friend-list-nick-regexp
"\\(.+\\)¤µ¤ó([0-9]+)")
@@ -1079,19 +1096,25 @@ 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 ()
@@ -1131,28 +1154,42 @@ 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]+\\)\\(.*?\\)")
-;;;###autoload
-(defun mixi-get-logs (&optional range)
- "Get logs."
- (let ((items (mixi-get-matched-items (mixi-log-list-page)
+(defun mixi-get-logs-internal (list-page &optional range)
+ (let ((items (mixi-get-matched-items list-page
mixi-log-list-regexp
- range)))
+ range))
+ (year (nth 5 (decode-time (current-time))))
+ (month (nth 4 (decode-time (current-time)))))
(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)))))
+ (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."
+ (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"))
@@ -1199,13 +1236,13 @@ 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-title-regexp
"
-
+
- \\([^<\n]+\\)\\(\\)?")
(defconst mixi-diary-time-regexp
"
- \\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü\\([0-9]+\\):\\([0-9]+\\)
")
@@ -1450,7 +1487,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)
@@ -1915,7 +1953,8 @@ Increase this value when unexpected error frequently occurs."
(mixi-post-error 'cannot-find-key community)))
(setq fields `(("post_key" . ,post-key)
("bbs_title" . ,title)
- ("bbs_body" . ,content)
+ ("bbs_body" . ,(mixi-replace-tab-and-space-to-nbsp
+ content))
("submit" . "confirm")))
(with-mixi-post-form (mixi-post-topic-page community) fields
(unless (re-search-forward mixi-post-succeed-regexp nil t)
@@ -2328,10 +2367,10 @@ Increase this value when unexpected error frequently occurs."
\\(
| ¼«Ê¬¤Î¥³¥á¥ó¥È¤òºï½ü¤¹¤ë
\\|\\)
-
+*
-+
+*
-
\\(\\(.\\|\r?\n\\)*?\\)
@@ -2514,17 +2553,20 @@ Increase this value when unexpected error frequently occurs."
(setq fields
`(("post_key" . ,post-key)
("owner_id" . ,(mixi-friend-id (mixi-diary-owner parent)))
- ("comment_body" . ,content)
+ ("comment_body" . ,(mixi-replace-tab-and-space-to-nbsp
+ content))
("submit" . "confirm")))
(setq fields `(("post_key" . ,post-key)
- ("comment" . ,content)
+ ("comment" . ,(mixi-replace-tab-and-space-to-nbsp
+ content))
("submit" . "confirm"))))
(with-mixi-post-form (funcall page parent) fields
(unless (re-search-forward mixi-post-succeed-regexp nil t)
(mixi-post-error 'cannot-find-succeed parent)))))
;; Message object.
-(defconst mixi-message-box-list '(inbox outbox savebox thrash)) ; thrash?
+(defconst mixi-message-box-list
+ '(inbox outbox savebox thrash noticebox)) ; thrash?
(defmacro mixi-message-box-p (box)
`(memq ,box mixi-message-box-list))
@@ -2560,35 +2602,39 @@ Increase this value when unexpected error frequently occurs."
`(concat "/view_message.pl?id=" (mixi-message-id ,message)
"&box=" (mixi-message-box ,message)))
-(defconst mixi-message-owner-regexp
- "\\(º¹½Ð¿Í\\|°¸ Àè\\) : \\(.*\\)\\(\\|\\)")
-(defconst mixi-message-time-regexp
-"Æü\\(¡¡\\| \\)ÉÕ : \\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\)»þ\\([0-9]+\\)ʬ ")
(defconst mixi-message-title-regexp
-"·ï\\(¡¡\\| \\)̾ : \\(.*\\)\n?")
+"