X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=mixi.el;h=b0ee69ed2c67b8430c9ccd1d6637eb6e5f343c4f;hb=94409b948c5b2330fd4f19ed26d9423539044bb7;hp=0f403de8cc80375c766117ed2f703bd025b785cf;hpb=ea7fbcf0f2640f117515ef1695f68135e3ebc591;p=elisp%2Fmixi.git
diff --git a/mixi.el b/mixi.el
index 0f403de..b0ee69e 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:
@@ -29,18 +29,21 @@
;; * mixi-get-friends
;; * mixi-get-favorites
;; * mixi-get-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
;;
;; APIs for posting:
@@ -52,7 +55,7 @@
;;
;; Utilities:
;;
-;; * mixi-remove-markup
+;; * mixi-remove-markup (half broken)
;; Examples:
;;
@@ -135,6 +138,8 @@
(autoload 'w3m-retrieve "w3m")
(autoload 'url-retrieve-synchronously "url"))
+(defconst mixi-revision "$Revision: 1.179 $")
+
(defgroup mixi nil
"API library for accessing to mixi."
:group 'hypermedia)
@@ -324,13 +329,13 @@ Increase this value when unexpected error frequently occurs."
(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)
@@ -346,7 +351,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))))))
@@ -387,7 +392,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))))
@@ -825,36 +830,29 @@ Increase this value when unexpected error frequently occurs."
`(concat "/show_profile.pl?id=" (mixi-friend-id ,friend)))
(defconst mixi-friend-nick-regexp
- "
?
-\\(.*\\)¤µ¤ó([0-9]+)")
+ "
\\(.*\\)¤µ¤ó([0-9]+) ")
(defconst mixi-friend-name-regexp
- "̾\\( \\| \\)Á°
-
-?\\(.+?\\)\\( \\| ̾Á°\n?\\(.+?\\)\\( \\)")
(defconst mixi-friend-sex-regexp
- "À\\( \\| \\)ÊÌ
-
-?\\([Ã˽÷]\\)À\\( \\| ÀÊÌ\n?\\([Ã˽÷]\\)À\\( \\)")
(defconst mixi-friend-address-regexp
- "¸½½»½ê
-\\(.+?\\)\\( \\| ¸½½»½ê\n?\\(.+?\\)\\( \\)")
(defconst mixi-friend-age-regexp
- "ǯ\\( \\| \\)Îð\n\\([0-9]+\\)ºÐ\\( \\| ǯÎð\n?\\([0-9]+\\)ºÐ\\( \\)")
(defconst mixi-friend-birthday-regexp
- "ÃÂÀ¸Æü\n\\([0-9]+\\)·î\\([0-9]+\\)Æü\\( \\| ÃÂÀ¸Æü\n?\\([0-9]+\\)·î\\([0-9]+\\)Æü\\( \\)")
(defconst mixi-friend-blood-type-regexp
- "·ì±Õ·¿\n\\([ABO]B?\\)·¿\\( \\| ·ì±Õ·¿\n?\\([ABO]B?\\)·¿\\( \\)")
(defconst mixi-friend-birthplace-regexp
- "½Ð¿ÈÃÏ\n?\n\\(.+?\\)\\( \\| ½Ð¿ÈÃÏ\n?\\(.+?\\)\\( \\)")
(defconst mixi-friend-hobby-regexp
- "¼ñ\\( \\| \\)Ì£\n\\(.+?\\)\\( \\| ¼ñÌ£\n?\\(.+?\\)\\( \\)")
(defconst mixi-friend-job-regexp
- "¿¦\\( \\| \\)¶È\n\\(.+?\\)\\( \\| ¿¦¶È\n?\\(.+?\\)\\( \\)")
(defconst mixi-friend-organization-regexp
- "½ê\\( \\| \\)°\n]*>\\(.+?\\)\\( \\| ½ê°\n?\\(.+?\\)\\( \\)")
(defconst mixi-friend-profile-regexp
- "¼«¸Ê¾Ò²ð
-\\(.+\\) ")
+ " ¼«¸Ê¾Ò²ð \n?\\(.+?\\) ")
(defun mixi-realize-friend (friend)
"Realize a FRIEND."
@@ -863,17 +861,17 @@ Increase this value when unexpected error frequently occurs."
(with-mixi-retrieve (mixi-friend-page friend)
(let ((case-fold-search t))
(if (re-search-forward mixi-friend-nick-regexp nil t)
- (mixi-friend-set-nick friend (match-string 4))
+ (mixi-friend-set-nick friend (match-string 1))
(mixi-realization-error 'cannot-find-nick friend))
(when (re-search-forward mixi-friend-name-regexp nil t)
- (mixi-friend-set-name friend (match-string 2)))
+ (mixi-friend-set-name friend (match-string 1)))
(when (re-search-forward mixi-friend-sex-regexp nil t)
- (mixi-friend-set-sex friend (if (string= (match-string 2) "ÃË")
+ (mixi-friend-set-sex friend (if (string= (match-string 1) "ÃË")
'male 'female)))
(when (re-search-forward mixi-friend-address-regexp nil t)
(mixi-friend-set-address friend (match-string 1)))
(when (re-search-forward mixi-friend-age-regexp nil t)
- (mixi-friend-set-age friend (string-to-number (match-string 2))))
+ (mixi-friend-set-age friend (string-to-number (match-string 1))))
(when (re-search-forward mixi-friend-birthday-regexp nil t)
(mixi-friend-set-birthday
friend (list (string-to-number (match-string 1))
@@ -883,11 +881,11 @@ Increase this value when unexpected error frequently occurs."
(when (re-search-forward mixi-friend-birthplace-regexp nil t)
(mixi-friend-set-birthplace friend (match-string 1)))
(when (re-search-forward mixi-friend-hobby-regexp nil t)
- (mixi-friend-set-hobby friend (split-string (match-string 2) ", ")))
+ (mixi-friend-set-hobby friend (split-string (match-string 1) ", ")))
(when (re-search-forward mixi-friend-job-regexp nil t)
- (mixi-friend-set-job friend (match-string 2)))
+ (mixi-friend-set-job friend (match-string 1)))
(when (re-search-forward mixi-friend-organization-regexp nil t)
- (mixi-friend-set-organization friend (match-string 2)))
+ (mixi-friend-set-organization friend (match-string 1)))
(when (re-search-forward mixi-friend-profile-regexp nil t)
(mixi-friend-set-profile friend (match-string 1)))))
(mixi-object-touch friend)))
@@ -1062,7 +1060,7 @@ Increase this value when unexpected error frequently occurs."
(defconst mixi-friend-list-id-regexp
"\\(.+\\)¤µ¤ó([0-9]+)")
+ "\\(.+\\)¤µ¤ó([0-9]+) ")
;;;###autoload
(defun mixi-get-friends (&rest friend-or-range)
@@ -1151,6 +1149,23 @@ Increase this value when unexpected error frequently occurs."
(string-to-number (nth 0 item)))))
items)))
+;; 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-friend (nth 0 item) (nth 1 item)))
+ items)))
+
;; Diary object.
(defvar mixi-diary-cache (make-hash-table :test 'equal))
(defun mixi-make-diary (owner id &optional comment-count time title content)
@@ -1182,13 +1197,18 @@ Increase this value when unexpected error frequently occurs."
(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\\)*?\\)\\(\t\\|\r?\n\\)
")
+ "
+\\(\\(.\\|\r?\n\\)*?\\)
+
")
(defun mixi-realize-diary (diary &optional page)
"Realize a DIARY."
@@ -1199,19 +1219,19 @@ Increase this value when unexpected error frequently occurs."
(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))
+ (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 7))
- (string-to-number (match-string 6))
+ 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 2))
+ (string-to-number (match-string 1))))
(mixi-realization-error 'cannot-find-time 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-content-regexp nil t)
(mixi-diary-set-content diary (match-string 1))
(mixi-realization-error 'cannot-find-content diary)))))
@@ -1287,9 +1307,9 @@ 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]+\\)·î\\([0-9]+\\)Æü\n?\\([0-9]+\\):\\([0-9]+\\)
+")
;;;###autoload
(defun mixi-get-diaries (&rest friend-or-range)
@@ -1308,22 +1328,22 @@ Increase this value when unexpected error frequently occurs."
mixi-diary-list-regexp
range)))
(mapcar (lambda (item)
- (mixi-make-diary friend (nth 6 item) nil
+ (mixi-make-diary friend (nth 1 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)))
+ 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]+\\)
+\\(.+\\) (\\(.*\\))\\(ºîÀ®\\|½ñ¤¹þ¤ß\\)¤¬´°Î»¤·¤Þ¤·¤¿¡£È¿±Ç¤Ë»þ´Ö¤¬¤«¤«¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¤Î¤Ç¡¢É½¼¨¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¾¯¡¹¤ªÂÔ¤Á¤¯¤À¤µ¤¤¡£")
+ "
\\(ºîÀ®\\|½ñ¤¹þ¤ß\\)¤¬´°Î»¤·¤Þ¤·¤¿¡£È¿±Ç¤Ë»þ´Ö¤¬¤«¤«¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¤Î¤Ç¡¢É½¼¨¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¾¯¡¹¤ªÂÔ¤Á¤¯¤À¤µ¤¤¡£
")
;; FIXME: Support photos.
;;;###autoload
@@ -1458,40 +1478,35 @@ 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
- "\\(.+\\) ")
+ " ")
+ "