-;; mixi.el --- API library for accessing to Mixi
+;; mixi.el --- API library for accessing to mixi
;; Copyright (C) 2005,2006 OHASHI Akira
;;; Code:
-(require 'w3m)
+(require 'url "url" t)
+(require 'w3m "w3m" t)
(eval-when-compile (require 'cl))
(defgroup mixi nil
- "API library for accessing to Mixi."
+ "API library for accessing to mixi."
:group 'hypermedia)
(defcustom mixi-url "http://mixi.jp"
- "*The URL of Mixi."
+ "*The URL of mixi."
:type 'string
:group 'mixi)
(defcustom mixi-coding-system 'euc-jp
- "*Coding system for Mixi."
+ "*Coding system for mixi."
:type 'coding-system
:group 'mixi)
+(defcustom mixi-retrieve-function
+ (if (and (require 'url "url" t)
+ (fboundp 'url-retrieve-synchronously))
+ 'mixi-w3-retrieve 'mixi-w3m-retrieve)
+ "*The function for retrieving."
+ :type '(choice (const :tag "Using w3" mixi-w3-retrieve)
+ (const :tag "Using w3m" mixi-w3m-retrieve)
+ (function :format "Other function: %v\n" :size 0))
+ :group 'mixi)
+
(defcustom mixi-default-email nil
"*Default E-mail address that is used to login automatically."
:type '(choice (string :tag "E-mail address")
:group 'mixi)
(defcustom mixi-accept-adult-contents t
- "*"
+ "*If non-nil, accept to access to the adult contents."
:type 'boolean
:group 'mixi)
-(defcustom mixi-continuously-access-interval 3.0
- "*Time interval between each Mixi access.
+(defcustom mixi-continuously-access-interval 4.0
+ "*Time interval between each mixi access.
Increase this value when unexpected error frequently occurs."
:type 'number
:group 'mixi)
:type 'directory
:group 'mixi)
-(defcustom mixi-friend-max-pages 10
- "*Number of pages which is retrieved for friends."
- :type '(choice (integer :tag "Number of pages")
- (const :tag "Infinity" nil))
- :group 'mixi)
-
-(defcustom mixi-favorite-max-pages nil
- "*Number of pages which is retrieved for favorites."
- :type '(choice (integer :tag "Number of pages")
- (const :tag "Infinity" nil))
- :group 'mixi)
-
-(defcustom mixi-log-max-pages 1
- "*Number of pages which is retrieved for logs."
- :type '(choice (integer :tag "Number of pages")
- (const :tag "Infinity" nil))
- :group 'mixi)
-
-(defcustom mixi-diary-max-pages nil
- "*Number of pages which is retrieved for diaries."
- :type '(choice (integer :tag "Number of pages")
- (const :tag "Infinity" nil))
- :group 'mixi)
-
-(defcustom mixi-new-diary-max-pages nil
- "*Number of pages which is retrieved for new diaries."
- :type '(choice (integer :tag "Number of pages")
- (const :tag "Infinity" nil))
- :group 'mixi)
-
-(defcustom mixi-community-max-pages nil
- "*Number of pages which is retrieved for communities."
- :type '(choice (integer :tag "Number of pages")
- (const :tag "Infinity" nil))
- :group 'mixi)
-
-(defcustom mixi-topic-max-pages nil
- "*Number of pages which is retrieved for topics."
- :type '(choice (integer :tag "Number of pages")
- (const :tag "Infinity" nil))
- :group 'mixi)
-
-(defcustom mixi-new-comment-max-pages nil
- "*Number of pages which is retrieved for new comments."
- :type '(choice (integer :tag "Number of pages")
- (const :tag "Infinity" nil))
- :group 'mixi)
-
-(defcustom mixi-new-topic-max-pages nil
- "*Number of pages which is retrieved for new topics."
- :type '(choice (integer :tag "Number of pages")
- (const :tag "Infinity" nil))
- :group 'mixi)
-
-;; FIXME: defcustom regexp.
-
-(defcustom mixi-verbose t
- "*Flag controls whether `mixi' should be verbose.
-If it is non-ni, the `w3m-verbose' variable will be bound to nil
-while `mixi' is waiting for a server's response."
- :type 'boolean
- :group 'mixi)
-
(defvar mixi-me nil)
;; Utilities.
(defmacro mixi-message (string)
- `(concat "[Mixi] " ,string))
+ `(concat "[mixi] " ,string))
(defconst mixi-message-adult-contents
"¤³¤Î¥Ú¡¼¥¸¤«¤éÀè¤Ï¥¢¥À¥ë¥È¡ÊÀ®¿Í¸þ¤±¡Ë¥³¥ó¥Æ¥ó¥Ä¤¬´Þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¡£<br>
¼õ¤±¤é¤ì¤Þ¤·¤¿¤Î¤Ç¡¢°ì»þŪ¤ËÁàºî¤òÄä»ß¤µ¤»¤Æ¤¤¤¿¤À¤¤Þ¤¹¡£¿½¤·Ìõ¤´¤¶¤¤¤Þ<br>
¤»¤ó¤¬¡¢¤·¤Ð¤é¤¯¤Î´Ö¤ªÂÔ¤Á¤¯¤À¤µ¤¤¡£")
-(defun mixi-retrieve (url &optional post-data)
+(defun mixi-retrieve-1 (buffer url &optional post-data)
+ (when (string-match mixi-message-adult-contents buffer)
+ (if mixi-accept-adult-contents
+ (setq buffer (funcall mixi-retrieve-function url "submit=agree"))
+ (setq buffer (funcall mixi-retrieve-function (concat url "?")))))
+ (when (string-match mixi-warning-continuously-accessing buffer)
+ (error (mixi-message "Continuously accessing")))
+ (if (not (string-match mixi-message-continuously-accessing buffer))
+ buffer
+ (message (mixi-message "Waiting for continuously accessing..."))
+ (sit-for mixi-continuously-access-interval)
+ (funcall mixi-retrieve-function url post-data)))
+
+(defun mixi-w3-retrieve (url &optional post-data)
+ "Retrieve the URL and return getted strings."
+ (if post-data
+ (progn
+ (setq url-request-method "POST")
+ (setq url-request-data post-data))
+ (setq url-request-method "GET")
+ (setq url-request-data nil))
+ (let* ((url (url-expand-file-name url mixi-url))
+ (buffer (url-retrieve-synchronously url))
+ ret)
+ (unless (bufferp buffer)
+ (error (mixi-message "Cannot retrieve")))
+ (with-current-buffer buffer
+ (goto-char (point-min))
+ (if (re-search-forward "HTTP/[0-9.]+ 302 Moved" nil t)
+ (if (re-search-forward
+ (concat "Location: " mixi-url "\\(.+\\)") nil t)
+ (setq ret (mixi-w3-retrieve (match-string 1) post-data))
+ (setq ret (mixi-w3-retrieve "/home.pl" post-data)))
+ (unless (re-search-forward "HTTP/[0-9.]+ 200 OK" nil t)
+ (error (mixi-message "Cannot retrieve")))
+ (search-forward "\n\n")
+ (setq ret (mm-decode-coding-string
+ (buffer-substring-no-properties (point) (point-max))
+ mixi-coding-system))
+ (kill-buffer buffer)
+ (setq ret (mixi-retrieve-1 ret url post-data))))
+ ret))
+
+(defun mixi-w3m-retrieve (url &optional post-data)
"Retrieve the URL and return getted strings."
(let ((url (w3m-expand-url url mixi-url)))
(with-temp-buffer
- (let ((w3m-verbose (if mixi-verbose nil w3m-verbose)))
- (if (not (string= (w3m-retrieve url nil nil post-data) "text/html"))
- (error (mixi-message "Cannot retrieve"))
- (w3m-decode-buffer url)
- (let ((ret (buffer-substring-no-properties (point-min) (point-max))))
- (when (string-match mixi-message-adult-contents ret)
- (if mixi-accept-adult-contents
- (setq ret (mixi-retrieve url "submit=agree"))
- (setq ret (mixi-retrieve (concat url "?")))))
- (when (string-match mixi-warning-continuously-accessing ret)
- (error (mixi-message "Continuously accessing")))
- (if (not (string-match mixi-message-continuously-accessing ret))
- ret
- (message (mixi-message "Waiting for continuously accessing..."))
- (sit-for mixi-continuously-access-interval)
- (mixi-retrieve url post-data))))))))
+ (if (not (string= (w3m-retrieve url nil nil post-data) "text/html"))
+ (error (mixi-message "Cannot retrieve"))
+ (w3m-decode-buffer url)
+ (let ((ret (buffer-substring-no-properties (point-min) (point-max))))
+ (mixi-retrieve-1 ret url post-data))))))
(defconst mixi-my-id-regexp
"<a href=\"add_diary\\.pl\\?id=\\([0-9]+\\)")
(defun mixi-login (&optional email password)
- "Login to Mixi."
+ "Login to mixi."
+ (when (and (eq mixi-retrieve-function 'mixi-w3m-retrieve)
+ (not w3m-use-cookies))
+ (error
+ (mixi-message
+ "Require to accept cookies. Please set `w3m-use-cookies' to t.")))
(let ((email (or email mixi-default-email
(read-from-minibuffer (mixi-message "Login Email: "))))
(password (or password mixi-default-password
(read-passwd (mixi-message "Login Password: ")))))
- (let (buffer)
- (setq buffer (mixi-retrieve "/login.pl"
- (concat "email=" email
- "&password=" password
- "&next_url=/home.pl"
- "&sticky=on")))
+ (let ((buffer (funcall mixi-retrieve-function "/login.pl"
+ (concat "email=" email
+ "&password=" password
+ "&next_url=/home.pl"
+ "&sticky=on"))))
(unless (string-match "url=/check\\.pl\\?n=" buffer)
(error (mixi-message "Cannot login")))
- (setq buffer (mixi-retrieve "/check.pl?n=home.pl"))
+ (setq buffer (funcall mixi-retrieve-function "/check.pl?n=home.pl"))
(if (string-match mixi-my-id-regexp buffer)
(setq mixi-me (mixi-make-friend
(string-to-number (match-string 1 buffer))))
(error (mixi-message "Cannot login"))))))
(defun mixi-logout ()
- (mixi-retrieve "/logout.pl"))
+ (funcall mixi-retrieve-function "/logout.pl"))
(defmacro with-mixi-retrieve (url &rest body)
`(let (buffer)
(when ,url
- (setq buffer (mixi-retrieve ,url))
+ (setq buffer (funcall mixi-retrieve-function ,url))
(when (string-match "login.pl" buffer)
(mixi-login)
- (setq buffer (mixi-retrieve ,url))))
+ (setq buffer (funcall mixi-retrieve-function ,url))))
,@body))
(put 'with-mixi-retrieve 'lisp-indent-function 'defun)
;; FIXME: Sort? Now order by newest.
(reverse ids)))
+;; stolen (and modified) from shimbun.el
(defun mixi-remove-markup (string)
"Remove markups from STRING."
(with-temp-buffer
(goto-char (point-min))
(while (re-search-forward "\r" nil t)
(replace-match "\n" t t)))
- (w3m-decode-entities)
(buffer-string)))
;; Cache.
-;; FIXME: Is Caches saved to files?
(defun mixi-cache-expired-p (object)
"Whether a cache of OBJECT is expired."
(defvar mixi-friend-cache (make-hash-table :test 'equal))
(defun mixi-make-friend (id &optional nick)
"Return a friend object."
- (mixi-make-cache id (cons 'mixi-friend (vector nil id nick nil))
+ (mixi-make-cache id (cons 'mixi-friend (vector nil id nick nil nil nil nil
+ nil nil nil nil nil nil nil))
mixi-friend-cache))
(defun mixi-make-me ()
(defconst mixi-friend-nick-regexp
"<img alt=\"\\*\" src=\"http://img\\.mixi\\.jp/img/dot0\\.gif\" width=\"1\" height=\"5\"><br>\n\\(.*\\)¤µ¤ó([0-9]+)")
-(defconst mixi-friend-name-regexp
- "<td BGCOLOR=#F2DDB7 WIDTH=80 NOWRAP><font COLOR=#996600>̾ Á°</font></td>\n<td WIDTH=345>\\([^<]+\\)</td>")
-(defconst mixi-my-name-regexp
- "<td BGCOLOR=#F2DDB7 WIDTH=80 NOWRAP><font COLOR=#996600>̾ Á°</font></td>\n\n<td WIDTH=345>\\([^<]+\\)</td>")
+(defconst mixi-friend-name-sex-regexp
+ "<td BGCOLOR=#F2DDB7 WIDTH=80 NOWRAP><font COLOR=#996600>̾\\( \\| \\)Á°</font></td>\n+<td WIDTH=345>\\([^<]+\\) (\\([Ã˽÷]\\)À)</td>")
+(defconst mixi-friend-address-regexp
+ "<td BGCOLOR=#F2DDB7><font COLOR=#996600>¸½½»½ê</font></td>\n<td>\\(.+\\)\\(\n.+\n\\)?</td></tr>")
+(defconst mixi-friend-age-regexp
+ "<td BGCOLOR=#F2DDB7><font COLOR=#996600>ǯ\\( \\| \\)Îð</font></td>\n<td>\\([0-9]+\\)ºÐ\\(\n.+\n\\)?</td></tr>")
+(defconst mixi-friend-birthday-regexp
+ "<td BGCOLOR=#F2DDB7><font COLOR=#996600>ÃÂÀ¸Æü</font></td>\n<td>\\([0-9]+\\)·î\\([0-9]+\\)Æü\\(\n.+\n\\)?</td></tr>")
+(defconst mixi-friend-blood-type-regexp
+ "<td BGCOLOR=#F2DDB7><font COLOR=#996600>·ì±Õ·¿</font></td>\n<td>\\([ABO]B?\\)·¿\\(\n\n\\)?</td></tr>")
+(defconst mixi-friend-birthplace-regexp
+ "<td BGCOLOR=#F2DDB7><font COLOR=#996600>½Ð¿ÈÃÏ</font>\n?</td>\n<td>\\(.+\\)\\(\n.+\n\\)?</td></tr>")
+(defconst mixi-friend-hobby-regexp
+ "<td BGCOLOR=#F2DDB7><font COLOR=#996600>¼ñ\\( \\| \\)Ì£</font></td>\n<td>\\(.+\\)</td></tr>")
+(defconst mixi-friend-job-regexp
+ "<td BGCOLOR=#F2DDB7><font COLOR=#996600>¿¦\\( \\| \\)¶È</font></td>\n<td>\\(.+\\)\\(\n.+\n\\)?</td></tr>")
+(defconst mixi-friend-organization-regexp
+ "<td BGCOLOR=#F2DDB7><font COLOR=#996600>½ê\\( \\| \\)°</font></td>\n<td[^>]*>\\(.+\\)\\(\n.+\n\\)?</td></tr>")
+(defconst mixi-friend-profile-regexp
+ "<td BGCOLOR=#F2DDB7><font COLOR=#996600>¼«¸Ê¾Ò²ð</font></td>\n<td CLASS=h120>\\(.+\\)</td></tr>")
(defun mixi-friend-realize (friend)
"Realize a FRIEND."
;; FIXME: Check a expiration of cache?
(unless (mixi-friend-realize-p friend)
- (let (name)
+ (let (buf)
(with-mixi-retrieve (mixi-friend-page friend)
- (if (string-match mixi-friend-nick-regexp buffer)
- (mixi-friend-set-nick friend (match-string 1 buffer))
- (signal 'error (list 'cannot-find-nick friend)))
- (when (string-match mixi-friend-name-regexp buffer)
- (setq name (match-string 1 buffer))))
- ;; For getting my name.
- (unless name
+ (setq buf buffer))
+ (if (string-match mixi-friend-nick-regexp buf)
+ (mixi-friend-set-nick friend (match-string 1 buf))
+ (signal 'error (list 'cannot-find-nick friend)))
+ ;; For getting my profile.
+ (unless (string-match mixi-friend-name-sex-regexp buf)
(with-mixi-retrieve "/show_profile.pl"
- (if (string-match mixi-my-name-regexp buffer)
- (setq name (match-string 1 buffer))
- (signal 'error (list 'cannot-find-name friend)))))
- (mixi-friend-set-name friend name))
+ (setq buf buffer)))
+ (if (string-match mixi-friend-name-sex-regexp buf)
+ (progn
+ (mixi-friend-set-name friend (match-string 2 buf))
+ (mixi-friend-set-sex friend
+ (if (string= (match-string 3 buf) "ÃË")
+ 'male 'female)))
+ (signal 'error (list 'cannot-find-name-or-sex friend)))
+ (when (string-match mixi-friend-address-regexp buf)
+ (mixi-friend-set-address friend (match-string 1 buf)))
+ (when (string-match mixi-friend-age-regexp buf)
+ (mixi-friend-set-age
+ friend (string-to-number (match-string 2 buf))))
+ (when (string-match mixi-friend-birthday-regexp buf)
+ (mixi-friend-set-birthday
+ friend (list (string-to-number (match-string 1 buf))
+ (string-to-number (match-string 2 buf)))))
+ (when (string-match mixi-friend-blood-type-regexp buf)
+ (mixi-friend-set-blood-type friend (intern (match-string 1 buf))))
+ (when (string-match mixi-friend-birthplace-regexp buf)
+ (mixi-friend-set-birthplace friend (match-string 1 buf)))
+ (when (string-match mixi-friend-hobby-regexp buf)
+ (mixi-friend-set-hobby
+ friend (split-string (match-string 2 buf) ", ")))
+ (when (string-match mixi-friend-job-regexp buf)
+ (mixi-friend-set-job friend (match-string 2 buf)))
+ (when (string-match mixi-friend-organization-regexp buf)
+ (mixi-friend-set-organization friend (match-string 2 buf)))
+ (when (string-match mixi-friend-profile-regexp buf)
+ (mixi-friend-set-profile
+ friend (mixi-remove-markup (match-string 1 buf)))))
(mixi-friend-touch friend)))
(defun mixi-friend-realize-p (friend)
(mixi-friend-realize friend)
(aref (cdr friend) 3))
+(defun mixi-friend-sex (friend)
+ "Return the sex of FRIEND."
+ (unless (mixi-friend-p friend)
+ (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+ (mixi-friend-realize friend)
+ (aref (cdr friend) 4))
+
+(defun mixi-friend-address (friend)
+ "Return the address of FRIEND."
+ (unless (mixi-friend-p friend)
+ (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+ (mixi-friend-realize friend)
+ (aref (cdr friend) 5))
+
+(defun mixi-friend-age (friend)
+ "Return the age of FRIEND."
+ (unless (mixi-friend-p friend)
+ (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+ (mixi-friend-realize friend)
+ (aref (cdr friend) 6))
+
+(defun mixi-friend-birthday (friend)
+ "Return the birthday of FRIEND."
+ (unless (mixi-friend-p friend)
+ (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+ (mixi-friend-realize friend)
+ (aref (cdr friend) 7))
+
+(defun mixi-friend-blood-type (friend)
+ "Return the blood type of FRIEND."
+ (unless (mixi-friend-p friend)
+ (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+ (mixi-friend-realize friend)
+ (aref (cdr friend) 8))
+
+(defun mixi-friend-birthplace (friend)
+ "Return the birthplace of FRIEND."
+ (unless (mixi-friend-p friend)
+ (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+ (mixi-friend-realize friend)
+ (aref (cdr friend) 9))
+
+(defun mixi-friend-hobby (friend)
+ "Return the hobby of FRIEND."
+ (unless (mixi-friend-p friend)
+ (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+ (mixi-friend-realize friend)
+ (aref (cdr friend) 10))
+
+(defun mixi-friend-job (friend)
+ "Return the job of FRIEND."
+ (unless (mixi-friend-p friend)
+ (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+ (mixi-friend-realize friend)
+ (aref (cdr friend) 11))
+
+(defun mixi-friend-organization (friend)
+ "Return the organization of FRIEND."
+ (unless (mixi-friend-p friend)
+ (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+ (mixi-friend-realize friend)
+ (aref (cdr friend) 12))
+
+(defun mixi-friend-profile (friend)
+ "Return the pforile of FRIEND."
+ (unless (mixi-friend-p friend)
+ (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+ (mixi-friend-realize friend)
+ (aref (cdr friend) 13))
+
(defun mixi-friend-touch (friend)
"Set the timestamp of FRIEND."
(unless (mixi-friend-p friend)
(signal 'wrong-type-argument (list 'mixi-friend-p friend)))
(aset (cdr friend) 3 name))
+(defun mixi-friend-set-sex (friend sex)
+ "Set the sex of FRIEND."
+ (unless (mixi-friend-p friend)
+ (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+ (aset (cdr friend) 4 sex))
+
+(defun mixi-friend-set-address (friend address)
+ "Set the address of FRIEND."
+ (unless (mixi-friend-p friend)
+ (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+ (aset (cdr friend) 5 address))
+
+(defun mixi-friend-set-age (friend age)
+ "Set the age of FRIEND."
+ (unless (mixi-friend-p friend)
+ (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+ (aset (cdr friend) 6 age))
+
+(defun mixi-friend-set-birthday (friend birthday)
+ "Set the birthday of FRIEND."
+ (unless (mixi-friend-p friend)
+ (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+ (aset (cdr friend) 7 birthday))
+
+(defun mixi-friend-set-blood-type (friend blood-type)
+ "Set the blood type of FRIEND."
+ (unless (mixi-friend-p friend)
+ (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+ (aset (cdr friend) 8 blood-type))
+
+(defun mixi-friend-set-birthplace (friend birthplace)
+ "Set the birthplace of FRIEND."
+ (unless (mixi-friend-p friend)
+ (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+ (aset (cdr friend) 9 birthplace))
+
+(defun mixi-friend-set-hobby (friend hobby)
+ "Set the hobby of FRIEND."
+ (unless (mixi-friend-p friend)
+ (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+ (aset (cdr friend) 10 hobby))
+
+(defun mixi-friend-set-job (friend job)
+ "Set the job of FRIEND."
+ (unless (mixi-friend-p friend)
+ (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+ (aset (cdr friend) 11 job))
+
+(defun mixi-friend-set-organization (friend organization)
+ "Set the organization of FRIEND."
+ (unless (mixi-friend-p friend)
+ (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+ (aset (cdr friend) 12 organization))
+
+(defun mixi-friend-set-profile (friend profile)
+ "Set the profile of FRIEND."
+ (unless (mixi-friend-p friend)
+ (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=" (number-to-string
(defconst mixi-friend-list-nick-regexp
"<td valign=middle>\\(.+\\)¤µ¤ó([0-9]+)<br />")
+(defvar mixi-friend-max-pages 10)
(defun mixi-get-friends (&optional friend)
"Get friends of FRIEND."
(unless (or (null friend) (mixi-friend-p friend))
"<td BGCOLOR=#FDF9F2><font COLOR=#996600>̾ Á°</font></td>
<td COLSPAN=2 BGCOLOR=#FFFFFF>\\(.+\\)</td></tr>")
+(defvar mixi-favorite-max-pages nil)
(defun mixi-get-favorites ()
"Get favorites."
(let ((ids (mixi-get-matched-items (mixi-favorite-list-page)
(defconst mixi-log-list-regexp
"\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\) <a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.+\\)</a><br>")
+(defvar mixi-log-max-pages 1)
(defun mixi-get-logs ()
"Get logs."
(let ((items (mixi-get-matched-items (mixi-log-list-page)
(defconst mixi-diary-list-regexp
"<a href=\"view_diary\\.pl\\?id=\\([0-9]+\\)&owner_id=[0-9]+\">")
+(defvar mixi-diary-max-pages nil)
(defun mixi-get-diaries (&optional friend)
"Get diaries of FRIEND."
(unless (or (null friend) (mixi-friend-p friend))
(defconst mixi-new-diary-list-regexp
"<a class=\"new_link\" href=view_diary\\.pl\\?id=\\([0-9]+\\)&owner_id=\\([0-9]+\\)>")
+(defvar mixi-new-diary-max-pages nil)
(defun mixi-get-new-diaries ()
"Get new diaries."
(let ((items (mixi-get-matched-items (mixi-new-diary-list-page)
(defun mixi-make-community (id &optional name)
"Return a community object."
(mixi-make-cache id (cons 'mixi-community (vector nil id name nil nil nil
- nil))
+ nil nil nil nil))
mixi-community-cache))
(defmacro mixi-community-p (community)
"<td BGCOLOR=#F2DDB7><font COLOR=#996600>´ÉÍý¿Í</font></td>\n<td>\n\n<a href=\"\\(home\\.pl\\|show_friend\\.pl\\?id=\\([0-9]+\\)\\)\">\n\\(.+\\)</a>")
(defconst mixi-community-category-regexp
"<td BGCOLOR=#F2DDB7><font COLOR=#996600>¥«¥Æ¥´¥ê</font></td>\n<td>\\([^<]+\\)</td>")
+(defconst mixi-community-members-regexp
+ "<td BGCOLOR=#F2DDB7><font COLOR=#996600>¥á¥ó¥Ð¡¼¿ô</font></td>\n<td>\\([0-9]+\\)¿Í</td></tr>")
+(defconst mixi-community-open-level-regexp
+ "<td BGCOLOR=#F2DDB7><font COLOR=#996600>»²²Ã¾ò·ï¤È<br>¸ø³«¥ì¥Ù¥ë</font></td>
+<td>\\(.+\\)</td></tr>")
+(defconst mixi-community-authority-regexp
+ "<td BGCOLOR=#F2DDB7><font COLOR=#996600>¥È¥Ô¥Ã¥¯ºîÀ®¤Î¸¢¸Â</font></td>\n<td>\\(.+\\)</td></tr>")
(defconst mixi-community-description-regexp
"<td CLASS=h120>\\(.+\\)</td>")
(if (string-match mixi-community-category-regexp buffer)
(mixi-community-set-category community (match-string 1 buffer))
(signal 'error (list 'cannot-find-category community)))
+ (if (string-match mixi-community-members-regexp buffer)
+ (mixi-community-set-members
+ community (string-to-number (match-string 1 buffer)))
+ (signal 'error (list 'cannot-find-members community)))
+ (if (string-match mixi-community-open-level-regexp buffer)
+ (mixi-community-set-open-level community (match-string 1 buffer))
+ (signal 'error (list 'cannot-find-open-level community)))
+ (if (string-match mixi-community-authority-regexp buffer)
+ (mixi-community-set-authority community (match-string 1 buffer))
+ (signal 'error (list 'cannot-find-authority community)))
(if (string-match mixi-community-description-regexp buffer)
- (mixi-community-set-description community (match-string 1 buffer))
+ (mixi-community-set-description
+ community (mixi-remove-markup (match-string 1 buffer)))
(signal 'error (list 'cannot-find-description community)))))
(mixi-community-touch community)))
(mixi-community-realize community)
(aref (cdr community) 5))
+(defun mixi-community-members (community)
+ "Return the members of COMMUNITY."
+ (unless (mixi-community-p community)
+ (signal 'wrong-type-argument (list 'mixi-community-p community)))
+ (mixi-community-realize community)
+ (aref (cdr community) 6))
+
+(defun mixi-community-open-level (community)
+ "Return the open-level of COMMUNITY."
+ (unless (mixi-community-p community)
+ (signal 'wrong-type-argument (list 'mixi-community-p community)))
+ (mixi-community-realize community)
+ (aref (cdr community) 7))
+
+(defun mixi-community-authority (community)
+ "Return the authority of COMMUNITY."
+ (unless (mixi-community-p community)
+ (signal 'wrong-type-argument (list 'mixi-community-p community)))
+ (mixi-community-realize community)
+ (aref (cdr community) 8))
+
(defun mixi-community-description (community)
"Return the description of COMMUNITY."
(unless (mixi-community-p community)
(signal 'wrong-type-argument (list 'mixi-community-p community)))
(mixi-community-realize community)
- (aref (cdr community) 6))
+ (aref (cdr community) 9))
(defun mixi-community-touch (community)
"Set the timestamp of COMMUNITY."
(signal 'wrong-type-argument (list 'mixi-community-p community)))
(aset (cdr community) 5 category))
+(defun mixi-community-set-members (community members)
+ "Set the name of COMMUNITY."
+ (unless (mixi-community-p community)
+ (signal 'wrong-type-argument (list 'mixi-community-p community)))
+ (aset (cdr community) 6 members))
+
+(defun mixi-community-set-open-level (community open-level)
+ "Set the name of COMMUNITY."
+ (unless (mixi-community-p community)
+ (signal 'wrong-type-argument (list 'mixi-community-p community)))
+ (aset (cdr community) 7 open-level))
+
+(defun mixi-community-set-authority (community authority)
+ "Set the name of COMMUNITY."
+ (unless (mixi-community-p community)
+ (signal 'wrong-type-argument (list 'mixi-community-p community)))
+ (aset (cdr community) 8 authority))
+
(defun mixi-community-set-description (community description)
"Set the name of COMMUNITY."
(unless (mixi-community-p community)
(signal 'wrong-type-argument (list 'mixi-community-p community)))
- (aset (cdr community) 6 description))
+ (aset (cdr community) 9 description))
(defmacro mixi-community-list-page (&optional friend)
`(concat "/list_community.pl?page=%d"
(defconst mixi-community-list-name-regexp
"<td valign=middle>\\(.+\\)([0-9]+)</td>")
+(defvar mixi-community-max-pages nil)
(defun mixi-get-communities (&optional friend)
"Get communities of FRIEND."
(unless (or (null friend) (mixi-friend-p friend))
(defconst mixi-topic-list-regexp
"<a href=view_bbs\\.pl\\?id=\\([0-9]+\\)")
+(defvar mixi-topic-max-pages nil)
(defun mixi-get-topics (community)
"Get topics of COMMUNITY."
(unless (mixi-community-p community)
(defconst mixi-new-topic-list-regexp
"<a href=\"view_bbs\\.pl\\?id=\\([0-9]+\\)&comment_count=[0-9]+&comm_id=\\([0-9]+\\)\" class=\"new_link\">")
+(defvar mixi-new-topic-max-pages nil)
(defun mixi-get-new-topics ()
"Get new topics."
(let ((items (mixi-get-matched-items (mixi-new-topic-list-page)
(defun mixi-get-comments (parent)
"Get comments of PARENT."
(unless (mixi-object-p parent)
- (signal 'wrong-type-argument (list 'mixi-object-p object)))
+ (signal 'wrong-type-argument (list 'mixi-object-p parent)))
(let* ((name (mixi-object-name parent))
(list-page (intern (concat mixi-object-prefix name
"-comment-list-page")))
(defconst mixi-new-comment-list-regexp
"<a href=\"view_diary\\.pl\\?id=\\([0-9]+\\)&owner_id=\\([0-9]+\\)&comment_count=[0-9]+\" class=\"new_link\">")
+(defvar mixi-new-comment-max-pages nil)
(defun mixi-get-new-comments ()
"Get new comments."
(let ((items (mixi-get-matched-items (mixi-new-comment-list-page)
(mixi-get-comments diary)))
items)))
-;;
-
-;; FIXME: Move to the class method.
-
-;; FIXME: When it got some results, this function doesn't work fine.
-(defun mixi-friend-to-id (friend)
- (with-mixi-retrieve (concat "/search.pl?submit=main&nickname="
- (w3m-url-encode-string friend
- mixi-coding-system))
- (when (string-match "show_friend\\.pl\\?id=\\([0-9]+\\)" buffer)
- (string-to-number (match-string 1 buffer)))))
-
-;; FIXME: When it got some results, this function doesn't work fine.
-(defun mixi-community-to-id (community)
- (with-mixi-retrieve (concat "/search_community.pl?sort="
- "&type=com&submit=main&keyword="
- (w3m-url-encode-string community
- mixi-coding-system))
- (when (string-match "view_community\\.pl\\?id=\\([0-9]+\\)" buffer)
- (string-to-number (match-string 1 buffer)))))
-
(provide 'mixi)
;;; mixi.el ends here