1 ;; mixi.el --- API library for accessing to mixi
3 ;; Copyright (C) 2005,2006 OHASHI Akira
5 ;; Author: OHASHI Akira <bg66@koka-in.org>
6 ;; Keywords: hypermedia
8 ;; This file is *NOT* a part of Emacs.
10 ;; This program is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with this program; if not, you can either send email to this
22 ;; program's maintainer or write to: The Free Software Foundation,
23 ;; Inc.; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 ;; API for getting contents:
30 ;; * mixi-get-favorites
33 ;; * mixi-get-new-diaries
34 ;; * mixi-search-diaries
35 ;; * mixi-get-communities
36 ;; * mixi-search-communities
38 ;; * mixi-get-new-bbses
39 ;; * mixi-search-bbses
40 ;; * mixi-get-comments
41 ;; * mixi-get-new-comments
42 ;; * mixi-get-messages
43 ;; * mixi-get-introductions
47 ;; * mixi-remove-markup
51 ;; Display newest 3 diaries like a mail format.
54 ;; (buffer (get-buffer-create "*temp*"))
55 ;; (format "%Y/%m/%d %H:%M"))
56 ;; (pop-to-buffer buffer)
57 ;; (mapc (lambda (diary)
58 ;; (let ((subject (mixi-diary-title diary))
59 ;; (from (mixi-friend-nick (mixi-diary-owner diary)))
60 ;; (date (format-time-string format (mixi-diary-time diary)))
61 ;; (body (mixi-remove-markup (mixi-diary-content diary))))
62 ;; (insert "From: " from "\n"
63 ;; "Subject: " subject "\n"
64 ;; "Date: " date "\n\n"
66 ;; (mixi-get-new-diaries range))
67 ;; (set-buffer-modified-p nil)
68 ;; (setq buffer-read-only t)
69 ;; (goto-char (point-min)))
71 ;; Display newest 3 diaries including newest 3 comments like a mail format.
72 ;; Comments are displayed like a reply mail.
75 ;; (buffer (get-buffer-create "*temp*"))
76 ;; (format "%Y/%m/%d %H:%M"))
77 ;; (pop-to-buffer buffer)
78 ;; (mapc (lambda (diary)
79 ;; (let ((subject (mixi-diary-title diary))
80 ;; (from (mixi-friend-nick (mixi-diary-owner diary)))
81 ;; (date (format-time-string format (mixi-diary-time diary)))
82 ;; (body (mixi-remove-markup (mixi-diary-content diary))))
83 ;; (insert "From: " from "\n"
84 ;; "Subject: " subject "\n"
85 ;; "Date: " date "\n\n"
87 ;; (mapc (lambda (comment)
88 ;; (let ((from (mixi-friend-nick
89 ;; (mixi-comment-owner comment)))
90 ;; (subject (concat "Re: " subject))
91 ;; (date (format-time-string
92 ;; format (mixi-comment-time comment)))
93 ;; (body (mixi-remove-markup
94 ;; (mixi-comment-content comment))))
95 ;; (insert "From: " from "\n"
96 ;; "Subject: " subject "\n"
97 ;; "Date: " date "\n\n"
99 ;; (mixi-get-comments diary range))))
100 ;; (mixi-get-new-diaries range))
101 ;; (set-buffer-modified-p nil)
102 ;; (setq buffer-read-only t)
103 ;; (goto-char (point-min)))
107 ;; If you have bug reports and/or suggestions for improvement, please
108 ;; send them via <URL:http://mixi.jp/view_community.pl?id=1596390>.
112 (eval-when-compile (require 'cl))
115 "API library for accessing to mixi."
118 (defcustom mixi-url "http://mixi.jp"
123 (defcustom mixi-directory (expand-file-name "~/.mixi")
124 "*Where to look for mixi files."
128 (defcustom mixi-coding-system 'euc-jp
129 "*Coding system for mixi."
133 (defcustom mixi-curl-program "curl"
134 "*The program name of `curl'."
138 (defcustom mixi-curl-cookie-file (expand-file-name "~/.mixi-cookies.txt")
139 "*The location of cookie file created by `curl'."
143 (defcustom mixi-retrieve-function
144 (or (condition-case nil
147 (if (fboundp 'url-retrieve-synchronously)
155 (if (and (fboundp 'executable-find)
156 (executable-find mixi-curl-program))
158 (error "Can't set `mixi-retrieve-function'"))
159 "*The function for retrieving."
160 :type '(radio (const :tag "Using url" mixi-url-retrieve)
161 (const :tag "Using w3m" mixi-w3m-retrieve)
162 (const :tag "Using curl" mixi-curl-retrieve)
163 (function :format "Other function: %v\n" :size 0))
166 (defcustom mixi-default-email nil
167 "*Default E-mail address that is used to login automatically."
168 :type '(radio (string :tag "E-mail address")
169 (const :tag "Asked when it is necessary" nil))
172 (defcustom mixi-default-password nil
173 "*Default password that is used to login automatically."
174 :type '(radio (string :tag "Password")
175 (const :tag "Asked when it is necessary" nil))
178 (defcustom mixi-accept-adult-contents t
179 "*If non-nil, accept to access to the adult contents."
183 (defcustom mixi-continuously-access-interval 4.0
184 "*Time interval between each mixi access.
185 Increase this value when unexpected error frequently occurs."
189 (defcustom mixi-cache-expires nil
190 "*Seconds for expiration of a cached object."
191 :type '(radio (integer :tag "Expired seconds")
192 (const :tag "Don't expire" nil)
193 (const :tag "Don't cache" t))
196 ;; FIXME: Not implemented.
197 (defcustom mixi-cache-use-file t
198 "*If non-nil, caches are saved to files."
205 (defmacro mixi-message (&rest strings)
206 `(concat "[mixi] " ,@strings))
208 (defconst mixi-message-adult-contents
209 "¤³¤Î¥Ú¡¼¥¸¤«¤éÀè¤Ï¥¢¥À¥ë¥È¡ÊÀ®¿Í¸þ¤±¡Ë¥³¥ó¥Æ¥ó¥Ä¤¬´Þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¡£<br>
210 ±ÜÍ÷¤ËƱ°Õ¤µ¤ì¤¿Êý¤Î¤ß¡¢Àè¤Ø¤ª¿Ê¤ß¤¯¤À¤µ¤¤¡£")
211 (defconst mixi-message-continuously-accessing
212 "°ÂÄꤷ¤Æ¥µ¥¤¥È¤Î±¿±Ä¤ò¤ª¤³¤Ê¤¦°Ù¡¢´Ö³Ö¤ò¶õ¤±¤Ê¤¤Ï¢Â³Åª¤Ê¥Ú¡¼¥¸¤ÎÁ«°Ü¡¦¹¹<br>
213 ¿·¤ÏÀ©¸Â¤µ¤»¤Æ¤¤¤¿¤À¤¤¤Æ¤ª¤ê¤Þ¤¹¡£¤´ÌÂÏǤò¤ª¤«¤±¤¤¤¿¤·¤Þ¤¹¤¬¡¢¤·¤Ð¤é¤¯¤ª<br>
214 ÂÔ¤Á¤¤¤¿¤À¤¤¤Æ¤«¤éÁàºî¤ò¤ª¤³¤Ê¤Ã¤Æ¤¯¤À¤µ¤¤¡£")
215 (defconst mixi-warning-continuously-accessing
216 "´Ö³Ö¤ò¶õ¤±¤Ê¤¤Ï¢Â³Åª¤Ê¥Ú¡¼¥¸¤ÎÁ«°Ü¡¦¹¹¿·¤òÉÑÈˤˤª¤³¤Ê¤ï¤ì¤Æ¤¤¤ë¤³¤È¤¬¸«<br>
217 ¼õ¤±¤é¤ì¤Þ¤·¤¿¤Î¤Ç¡¢°ì»þŪ¤ËÁàºî¤òÄä»ß¤µ¤»¤Æ¤¤¤¿¤À¤¤Þ¤¹¡£¿½¤·Ìõ¤´¤¶¤¤¤Þ<br>
218 ¤»¤ó¤¬¡¢¤·¤Ð¤é¤¯¤Î´Ö¤ªÂÔ¤Á¤¯¤À¤µ¤¤¡£")
220 (defmacro mixi-retrieve (url &optional post-data)
221 `(funcall mixi-retrieve-function ,url ,post-data))
223 (defun mixi-parse-buffer (url buffer &optional post-data)
224 (when (string-match mixi-message-adult-contents buffer)
225 (if mixi-accept-adult-contents
226 (setq buffer (mixi-retrieve url "submit=agree"))
227 (setq buffer (mixi-retrieve (concat url "?")))))
228 (when (string-match mixi-warning-continuously-accessing buffer)
229 (error (mixi-message "Access denied. Please wait a while and increase "
230 "the value of `mixi-continuously-access-interval'.")))
231 (if (not (string-match mixi-message-continuously-accessing buffer))
233 (message (mixi-message "Waiting for continuously accessing..."))
234 (sit-for mixi-continuously-access-interval)
235 (mixi-retrieve url post-data)))
237 (defmacro mixi-expand-url (url)
238 `(if (string-match (concat "^" mixi-url) ,url)
240 (concat mixi-url ,url)))
242 (defun mixi-url-retrieve (url &optional post-data)
243 "Retrieve the URL and return gotten strings."
246 (setq url-request-method "POST")
247 (setq url-request-data post-data))
248 (setq url-request-method "GET")
249 (setq url-request-data nil))
250 (let* ((url (mixi-expand-url url))
251 (buffer (url-retrieve-synchronously url))
253 (unless (bufferp buffer)
254 (error (mixi-message "Cannot retrieve")))
255 (with-current-buffer buffer
256 (goto-char (point-min))
257 (while (looking-at "HTTP/[0-9]+\\.[0-9]+ [13][0-9][0-9]")
258 (delete-region (point) (re-search-forward "\r?\n\r?\n")))
259 (unless (looking-at "HTTP/[0-9]+\\.[0-9]+ 200")
260 (error (mixi-message "Cannot retrieve")))
261 (delete-region (point) (re-search-forward "\r?\n\r?\n"))
262 (setq ret (decode-coding-string (buffer-string) mixi-coding-system))
264 (mixi-parse-buffer url ret post-data))))
266 (defun mixi-w3m-retrieve (url &optional post-data)
267 "Retrieve the URL and return gotten strings."
268 (let ((url (mixi-expand-url url)))
270 (if (not (string= (w3m-retrieve url nil nil post-data) "text/html"))
271 (error (mixi-message "Cannot retrieve"))
272 (w3m-decode-buffer url)
273 (let ((ret (buffer-substring-no-properties (point-min) (point-max))))
274 (mixi-parse-buffer url ret post-data))))))
276 (defun mixi-curl-retrieve (url &optional post-data)
277 "Retrieve the URL and return gotten strings."
279 (if (fboundp 'set-buffer-multibyte)
280 (set-buffer-multibyte nil))
281 (let ((orig-mode (default-file-modes))
282 (coding-system-for-read 'binary)
283 (coding-system-for-write 'binary)
287 (set-default-file-modes 448)
289 (apply #'start-process "curl" (current-buffer)
291 (append (if post-data '("-d" "@-"))
293 "-b" mixi-curl-cookie-file
294 "-c" mixi-curl-cookie-file
295 (mixi-expand-url url)))))
296 (set-process-sentinel process #'ignore))
297 (set-default-file-modes orig-mode))
299 (process-send-string process (concat post-data "\n"))
300 (process-send-eof process))
301 (while (eq (process-status process) 'run)
302 (accept-process-output process 1))
303 (goto-char (point-min))
304 (while (looking-at "HTTP/[0-9]+\\.[0-9]+ [13][0-9][0-9]")
305 (delete-region (point) (re-search-forward "\r?\n\r?\n")))
306 (unless (looking-at "HTTP/[0-9]+\\.[0-9]+ 200")
307 (error (mixi-message "Cannot retrieve")))
308 (delete-region (point) (re-search-forward "\r?\n\r?\n"))
309 (setq ret (decode-coding-string (buffer-string) mixi-coding-system))
310 (mixi-parse-buffer url ret post-data))))
312 (defconst mixi-my-id-regexp
313 "<a href=\"add_diary\\.pl\\?id=\\([0-9]+\\)")
315 (defun mixi-login (&optional email password)
317 (when (and (eq mixi-retrieve-function 'mixi-w3m-retrieve)
318 (not w3m-use-cookies))
319 (error (mixi-message "Require to accept cookies. Please set "
320 "`w3m-use-cookies' to t.")))
321 (let ((email (or email mixi-default-email
322 (read-from-minibuffer (mixi-message "Login Email: "))))
323 (password (or password mixi-default-password
324 (read-passwd (mixi-message "Login Password: ")))))
325 (let ((buffer (mixi-retrieve "/login.pl"
326 (concat "email=" email
327 "&password=" password
330 (unless (string-match "url=/check\\.pl\\?n=" buffer)
331 (error (mixi-message "Cannot login")))
332 (setq buffer (mixi-retrieve "/check.pl?n=home.pl"))
333 (if (string-match mixi-my-id-regexp buffer)
334 (setq mixi-me (mixi-make-friend (match-string 1 buffer)))
335 (error (mixi-message "Cannot login"))))))
337 (defun mixi-logout ()
338 (mixi-retrieve "/logout.pl"))
340 (defmacro with-mixi-retrieve (url &rest body)
343 (setq buffer (mixi-retrieve ,url))
344 (when (string-match "login.pl" buffer)
346 (setq buffer (mixi-retrieve ,url))))
348 (put 'with-mixi-retrieve 'lisp-indent-function 'defun)
349 (put 'with-mixi-retrieve 'edebug-form-spec '(form body))
351 (defun mixi-get-matched-items (url regexp &optional range)
352 "Get matched items to REGEXP in URL."
356 (while (or (null range) (< (length ids) range))
357 (with-mixi-retrieve (format url page)
360 (while (and (string-match regexp buffer pos)
361 (or (null range) (< (length ids) range)))
364 (while (match-string num buffer)
365 (setq list (cons (match-string num buffer) list))
367 (when (not (member (reverse list) ids))
369 (setq ids (cons (reverse list) ids)))
370 (setq pos (match-end (1- num)))))
376 ;; stolen (and modified) from shimbun.el
377 (defun mixi-remove-markup (string)
378 "Remove markups from STRING."
380 (insert (or string ""))
382 (goto-char (point-min))
383 (while (search-forward "<!--" nil t)
384 (delete-region (match-beginning 0)
385 (or (search-forward "-->" nil t)
387 (goto-char (point-min))
388 (while (re-search-forward "<[^>]+>" nil t)
389 (replace-match "" t t))
390 (goto-char (point-min))
391 (while (re-search-forward "
\r" nil t)
392 (replace-match "\n" t t)))
393 ;; FIXME: Decode entities.
396 ;; stolen (and modified) from w3m.el
398 (defun mixi-url-encode-and-quote-percent-string (string)
399 (apply (function concat)
403 ((eq char ?\n) ; newline
405 ((string-match "[-a-zA-Z0-9_:/.]" (char-to-string char)) ; xxx?
406 (char-to-string char)) ; printable
407 ((char-equal char ?\x20) ; space
410 (format "%%%%%02x" char)))) ; escape
411 ;; Coerce a string into a list of chars.
412 (append (encode-coding-string (or string "") mixi-coding-system)
416 (defconst mixi-object-prefix "mixi-")
418 (defmacro mixi-object-class (object)
421 (defmacro mixi-object-p (object)
422 `(let ((class (mixi-object-class ,object)))
423 (when (symbolp class)
424 (eq (string-match (concat "^" mixi-object-prefix)
425 (symbol-name class)) 0))))
427 (defun mixi-object-name (object)
428 "Return the name of OBJECT."
429 (unless (mixi-object-p object)
430 (signal 'wrong-type-argument (list 'mixi-object-p object)))
431 (let ((class (mixi-object-class object)))
432 (substring (symbol-name class) (length mixi-object-prefix))))
434 (defun mixi-read-object (exp)
435 "Read one Lisp expression as mixi object."
436 (if (mixi-object-p exp)
437 (let ((func (intern (concat mixi-object-prefix "make-"
438 (mixi-object-name exp))))
439 (args (mapcar (lambda (arg)
440 (mixi-read-object arg))
442 (let ((object (apply func (cdr args))))
444 (mixi-object-set-timestamp object (car args)))
448 (defun mixi-object-timestamp (object)
449 "Return the timestamp of OJBECT."
450 (unless (mixi-object-p object)
451 (signal 'wrong-type-argument (list 'mixi-object-p object)))
452 (aref (cdr object) 0))
453 (defalias 'mixi-object-realize-p 'mixi-object-timestamp)
455 (defun mixi-object-owner (object)
456 "Return the owner of OBJECT."
457 (unless (mixi-object-p object)
458 (signal 'wrong-type-argument (list 'mixi-object-p object)))
459 (let ((func (intern (concat mixi-object-prefix
460 (mixi-object-name object) "-owner"))))
461 (funcall func object)))
463 (defun mixi-object-id (object)
464 "Return the id of OBJECT."
465 (unless (mixi-object-p object)
466 (signal 'wrong-type-argument (list 'mixi-object-p object)))
467 (let ((func (intern (concat mixi-object-prefix
468 (mixi-object-name object) "-id"))))
469 (funcall func object)))
471 (defun mixi-object-time (object)
472 "Return the time of OBJECT."
473 (unless (mixi-object-p object)
474 (signal 'wrong-type-argument (list 'mixi-object-p object)))
475 (let ((func (intern (concat mixi-object-prefix
476 (mixi-object-name object) "-time"))))
477 (funcall func object)))
479 (defun mixi-object-title (object)
480 "Return the title of OBJECT."
481 (unless (mixi-object-p object)
482 (signal 'wrong-type-argument (list 'mixi-object-p object)))
483 (let ((func (intern (concat mixi-object-prefix
484 (mixi-object-name object) "-title"))))
485 (funcall func object)))
487 (defun mixi-object-content (object)
488 "Return the content of OBJECT."
489 (unless (mixi-object-p object)
490 (signal 'wrong-type-argument (list 'mixi-object-p object)))
491 (let ((func (intern (concat mixi-object-prefix
492 (mixi-object-name object) "-content"))))
493 (funcall func object)))
495 (defun mixi-object-set-timestamp (object timestamp)
496 "Set the timestamp of OBJECT."
497 (unless (mixi-object-p object)
498 (signal 'wrong-type-argument (list 'mixi-object-p object)))
499 (aset (cdr object) 0 timestamp))
501 (defmacro mixi-object-touch (object)
502 `(mixi-object-set-timestamp ,object (current-time)))
504 (defconst mixi-object-url-regexp
505 "/\\(show\\|view\\)_\\([a-z]+\\)\\.pl")
507 (defun mixi-make-object-from-url (url)
508 "Return a mixi object from URL."
509 (if (string-match mixi-object-url-regexp url)
510 (let ((name (match-string 2 url)))
511 (when (string= name "bbs")
513 (let ((func (intern (concat mixi-object-prefix "make-" name
516 (when (string-match "/home\\.pl" url)
517 (mixi-make-friend-from-url url))))
520 ;; stolen from time-date.el
521 (defun mixi-time-less-p (t1 t2)
522 "Say whether time value T1 is less than time value T2."
523 (unless (numberp (cdr t1))
524 (setq t1 (cons (car t1) (car (cdr t1)))))
525 (unless (numberp (cdr t2))
526 (setq t2 (cons (car t2) (car (cdr t2)))))
527 (or (< (car t1) (car t2))
528 (and (= (car t1) (car t2))
529 (< (cdr t1) (cdr t2)))))
531 (defun mixi-time-add (t1 t2)
532 "Add two time values. One should represent a time difference."
533 (unless (numberp (cdr t1))
534 (setq t1 (cons (car t1) (car (cdr t1)))))
535 (unless (numberp (cdr t2))
536 (setq t2 (cons (car t2) (car (cdr t2)))))
537 (let ((low (+ (cdr t1) (cdr t2))))
538 (cons (+ (car t1) (car t2) (lsh low -16)) low)))
540 ;; stolen from time-date.el
541 (defun mixi-seconds-to-time (seconds)
542 "Convert SECONDS (a floating point number) to a time value."
543 (cons (floor seconds 65536)
544 (floor (mod seconds 65536))))
546 (defun mixi-cache-expired-p (object)
547 "Whether a cache of OBJECT is expired."
548 (let ((timestamp (mixi-object-timestamp object)))
549 (unless (or (null mixi-cache-expires)
551 (if (numberp mixi-cache-expires)
553 (mixi-time-add timestamp (mixi-seconds-to-time mixi-cache-expires))
557 (defun mixi-make-cache (key value table)
558 "Make a cache object and return it."
559 (let ((cache (gethash key table)))
560 (if (and cache (not (mixi-cache-expired-p cache)))
562 (puthash key value table))))
564 (defconst mixi-cache-file-regexp "[a-z]+-cache$")
565 (defconst mixi-cache-regexp (concat mixi-object-prefix
566 mixi-cache-file-regexp))
568 (defun mixi-save-cache ()
569 (unless (file-directory-p mixi-directory)
570 (make-directory mixi-directory t))
571 (let ((caches (apropos-internal mixi-cache-regexp 'boundp)))
572 (mapc (lambda (symbol)
573 (with-temp-file (expand-file-name
574 (substring (symbol-name symbol)
575 (length mixi-object-prefix))
577 (let ((coding-system-for-write mixi-coding-system)
578 (cache (symbol-value symbol)))
579 (insert "#s(hash-table size "
580 (number-to-string (hash-table-count cache))
581 " test equal data (\n")
584 (let (print-level print-length)
585 (insert (prin1-to-string key) " "
586 (prin1-to-string value) "\n")))
591 ;; stolen (and modified) from lsdb.el
592 (defun mixi-read-cache (&optional marker)
593 "Read one Lisp expression as text from MARKER, return as Lisp object."
596 (if (looking-at "^#s(")
599 (forward-char 2);skip "#s"
600 (forward-sexp);move to the left paren
603 (buffer-disable-undo)
604 (insert-buffer-substring (marker-buffer marker)
606 (goto-char (point-min))
608 (let ((object (read (current-buffer)))
610 (if (eq 'hash-table (car object))
612 (setq data (plist-get (cdr object) 'data))
614 (pop data);throw it away
615 (mixi-read-object (pop data))))
619 (defun mixi-load-cache ()
620 (when (file-directory-p mixi-directory)
621 ;; FIXME: Load friend and community first.
622 (let ((files (directory-files mixi-directory t mixi-cache-file-regexp)))
624 (let ((buffer (find-file-noselect file)))
628 (goto-char (point-min))
629 (re-search-forward "^#s(")
630 (goto-char (match-beginning 0))
631 (mixi-read-cache (point-marker)))
632 (kill-buffer buffer))))
636 (defvar mixi-friend-cache (make-hash-table :test 'equal))
637 (defun mixi-make-friend (id &optional nick name sex address age birthday
638 blood-type birthplace hobby job organization
640 "Return a friend object."
641 (mixi-make-cache id (cons 'mixi-friend (vector nil id nick name sex address
642 age birthday blood-type
644 organization profile))
647 (defun mixi-make-me ()
648 "Return a my object."
650 (with-mixi-retrieve "/home.pl"
651 (if (string-match mixi-my-id-regexp buffer)
652 (setq mixi-me (mixi-make-friend (match-string 1 buffer)))
653 (signal 'error (list 'who-am-i)))))
656 (defconst mixi-friend-url-regexp
657 "/show_friend\\.pl\\?id=\\([0-9]+\\)")
659 (defun mixi-make-friend-from-url (url)
660 "Return a friend object from URL."
661 (if (string-match mixi-friend-url-regexp url)
662 (let ((id (match-string 1 url)))
663 (mixi-make-friend id))
664 (when (string-match "/home\\.pl" url)
667 (defmacro mixi-friend-p (friend)
668 `(eq (mixi-object-class ,friend) 'mixi-friend))
670 (defmacro mixi-friend-page (friend)
671 `(concat "/show_friend.pl?id=" (mixi-friend-id ,friend)))
673 (defconst mixi-friend-nick-regexp
674 "<img alt=\"\\*\" src=\"http://img\\.mixi\\.jp/img/dot0\\.gif\" width=\"1\" height=\"5\"><br>
\r?\n\\(.*\\)¤µ¤ó([0-9]+)")
675 (defconst mixi-friend-name-sex-regexp
676 "<td BGCOLOR=#F2DDB7 WIDTH=80 NOWRAP><font COLOR=#996600>̾\\( \\| \\)Á°</font></td>\n+<td WIDTH=345>\\([^<]+\\) (\\([Ã˽÷]\\)À)</td>")
677 (defconst mixi-friend-address-regexp
678 "<td BGCOLOR=#F2DDB7><font COLOR=#996600>¸½½»½ê</font></td>\n<td>\\(.+\\)\\(\n.+\n\\)?</td></tr>")
679 (defconst mixi-friend-age-regexp
680 "<td BGCOLOR=#F2DDB7><font COLOR=#996600>ǯ\\( \\| \\)Îð</font></td>\n<td>\\([0-9]+\\)ºÐ\\(\n.+\n\\)?</td></tr>")
681 (defconst mixi-friend-birthday-regexp
682 "<td BGCOLOR=#F2DDB7><font COLOR=#996600>ÃÂÀ¸Æü</font></td>\n<td>\\([0-9]+\\)·î\\([0-9]+\\)Æü\\(\n.+\n\\)?</td></tr>")
683 (defconst mixi-friend-blood-type-regexp
684 "<td BGCOLOR=#F2DDB7><font COLOR=#996600>·ì±Õ·¿</font></td>\n<td>\\([ABO]B?\\)·¿\\(\n\n\\)?</td></tr>")
685 (defconst mixi-friend-birthplace-regexp
686 "<td BGCOLOR=#F2DDB7><font COLOR=#996600>½Ð¿ÈÃÏ</font>\n?</td>\n<td>\\(.+\\)\\(\n.+\n\\)?</td></tr>")
687 (defconst mixi-friend-hobby-regexp
688 "<td BGCOLOR=#F2DDB7><font COLOR=#996600>¼ñ\\( \\| \\)Ì£</font></td>\n<td>\\(.+\\)</td></tr>")
689 (defconst mixi-friend-job-regexp
690 "<td BGCOLOR=#F2DDB7><font COLOR=#996600>¿¦\\( \\| \\)¶È</font></td>\n<td>\\(.+\\)\\(\n.+\n\\)?</td></tr>")
691 (defconst mixi-friend-organization-regexp
692 "<td BGCOLOR=#F2DDB7><font COLOR=#996600>½ê\\( \\| \\)°</font></td>\n<td[^>]*>\\(.+\\)\\(\n.+\n\\)?</td></tr>")
693 (defconst mixi-friend-profile-regexp
694 "<td BGCOLOR=#F2DDB7><font COLOR=#996600>¼«¸Ê¾Ò²ð</font></td>\n<td CLASS=h120>\\(.+\\)</td></tr>")
696 (defun mixi-friend-realize (friend)
698 ;; FIXME: Check a expiration of cache?
699 (unless (mixi-object-realize-p friend)
701 (with-mixi-retrieve (mixi-friend-page friend)
703 (if (string-match mixi-friend-nick-regexp buf)
704 (mixi-friend-set-nick friend (match-string 1 buf))
705 (signal 'error (list 'cannot-find-nick friend)))
706 ;; For getting my profile.
707 (unless (string-match mixi-friend-name-sex-regexp buf)
708 (with-mixi-retrieve (concat "/show_profile.pl?id="
709 (mixi-friend-id friend))
711 (if (string-match mixi-friend-name-sex-regexp buf)
713 (mixi-friend-set-name friend (match-string 2 buf))
714 (mixi-friend-set-sex friend
715 (if (string= (match-string 3 buf) "ÃË")
717 (signal 'error (list 'cannot-find-name-or-sex friend)))
718 (when (string-match mixi-friend-address-regexp buf)
719 (mixi-friend-set-address friend (match-string 1 buf)))
720 (when (string-match mixi-friend-age-regexp buf)
722 friend (string-to-number (match-string 2 buf))))
723 (when (string-match mixi-friend-birthday-regexp buf)
724 (mixi-friend-set-birthday
725 friend (list (string-to-number (match-string 1 buf))
726 (string-to-number (match-string 2 buf)))))
727 (when (string-match mixi-friend-blood-type-regexp buf)
728 (mixi-friend-set-blood-type friend (intern (match-string 1 buf))))
729 (when (string-match mixi-friend-birthplace-regexp buf)
730 (mixi-friend-set-birthplace friend (match-string 1 buf)))
731 (when (string-match mixi-friend-hobby-regexp buf)
732 (mixi-friend-set-hobby
733 friend (split-string (match-string 2 buf) ", ")))
734 (when (string-match mixi-friend-job-regexp buf)
735 (mixi-friend-set-job friend (match-string 2 buf)))
736 (when (string-match mixi-friend-organization-regexp buf)
737 (mixi-friend-set-organization friend (match-string 2 buf)))
738 (when (string-match mixi-friend-profile-regexp buf)
739 (mixi-friend-set-profile friend (match-string 1 buf))))
740 (mixi-object-touch friend)))
742 (defun mixi-friend-id (friend)
743 "Return the id of FRIEND."
744 (unless (mixi-friend-p friend)
745 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
746 (aref (cdr friend) 1))
748 (defun mixi-friend-nick (friend)
749 "Return the nick of FRIEND."
750 (unless (mixi-friend-p friend)
751 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
752 (unless (aref (cdr friend) 2)
753 (mixi-friend-realize friend))
754 (aref (cdr friend) 2))
756 (defun mixi-friend-name (friend)
757 "Return the name of FRIEND."
758 (unless (mixi-friend-p friend)
759 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
760 (mixi-friend-realize friend)
761 (aref (cdr friend) 3))
763 (defun mixi-friend-sex (friend)
764 "Return the sex of FRIEND."
765 (unless (mixi-friend-p friend)
766 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
767 (mixi-friend-realize friend)
768 (aref (cdr friend) 4))
770 (defun mixi-friend-address (friend)
771 "Return the address of FRIEND."
772 (unless (mixi-friend-p friend)
773 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
774 (mixi-friend-realize friend)
775 (aref (cdr friend) 5))
777 (defun mixi-friend-age (friend)
778 "Return the age of FRIEND."
779 (unless (mixi-friend-p friend)
780 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
781 (mixi-friend-realize friend)
782 (aref (cdr friend) 6))
784 (defun mixi-friend-birthday (friend)
785 "Return the birthday of FRIEND."
786 (unless (mixi-friend-p friend)
787 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
788 (mixi-friend-realize friend)
789 (aref (cdr friend) 7))
791 (defun mixi-friend-blood-type (friend)
792 "Return the blood type of FRIEND."
793 (unless (mixi-friend-p friend)
794 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
795 (mixi-friend-realize friend)
796 (aref (cdr friend) 8))
798 (defun mixi-friend-birthplace (friend)
799 "Return the birthplace of FRIEND."
800 (unless (mixi-friend-p friend)
801 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
802 (mixi-friend-realize friend)
803 (aref (cdr friend) 9))
805 (defun mixi-friend-hobby (friend)
806 "Return the hobby of FRIEND."
807 (unless (mixi-friend-p friend)
808 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
809 (mixi-friend-realize friend)
810 (aref (cdr friend) 10))
812 (defun mixi-friend-job (friend)
813 "Return the job of FRIEND."
814 (unless (mixi-friend-p friend)
815 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
816 (mixi-friend-realize friend)
817 (aref (cdr friend) 11))
819 (defun mixi-friend-organization (friend)
820 "Return the organization of FRIEND."
821 (unless (mixi-friend-p friend)
822 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
823 (mixi-friend-realize friend)
824 (aref (cdr friend) 12))
826 (defun mixi-friend-profile (friend)
827 "Return the pforile of FRIEND."
828 (unless (mixi-friend-p friend)
829 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
830 (mixi-friend-realize friend)
831 (aref (cdr friend) 13))
833 (defun mixi-friend-set-nick (friend nick)
834 "Set the nick of FRIEND."
835 (unless (mixi-friend-p friend)
836 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
837 (aset (cdr friend) 2 nick))
839 (defun mixi-friend-set-name (friend name)
840 "Set the name of FRIEND."
841 (unless (mixi-friend-p friend)
842 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
843 (aset (cdr friend) 3 name))
845 (defun mixi-friend-set-sex (friend sex)
846 "Set the sex of FRIEND."
847 (unless (mixi-friend-p friend)
848 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
849 (aset (cdr friend) 4 sex))
851 (defun mixi-friend-set-address (friend address)
852 "Set the address of FRIEND."
853 (unless (mixi-friend-p friend)
854 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
855 (aset (cdr friend) 5 address))
857 (defun mixi-friend-set-age (friend age)
858 "Set the age of FRIEND."
859 (unless (mixi-friend-p friend)
860 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
861 (aset (cdr friend) 6 age))
863 (defun mixi-friend-set-birthday (friend birthday)
864 "Set the birthday of FRIEND."
865 (unless (mixi-friend-p friend)
866 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
867 (aset (cdr friend) 7 birthday))
869 (defun mixi-friend-set-blood-type (friend blood-type)
870 "Set the blood type of FRIEND."
871 (unless (mixi-friend-p friend)
872 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
873 (aset (cdr friend) 8 blood-type))
875 (defun mixi-friend-set-birthplace (friend birthplace)
876 "Set the birthplace of FRIEND."
877 (unless (mixi-friend-p friend)
878 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
879 (aset (cdr friend) 9 birthplace))
881 (defun mixi-friend-set-hobby (friend hobby)
882 "Set the hobby of FRIEND."
883 (unless (mixi-friend-p friend)
884 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
885 (aset (cdr friend) 10 hobby))
887 (defun mixi-friend-set-job (friend job)
888 "Set the job of FRIEND."
889 (unless (mixi-friend-p friend)
890 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
891 (aset (cdr friend) 11 job))
893 (defun mixi-friend-set-organization (friend organization)
894 "Set the organization of FRIEND."
895 (unless (mixi-friend-p friend)
896 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
897 (aset (cdr friend) 12 organization))
899 (defun mixi-friend-set-profile (friend profile)
900 "Set the profile of FRIEND."
901 (unless (mixi-friend-p friend)
902 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
903 (aset (cdr friend) 13 profile))
905 (defmacro mixi-friend-list-page (&optional friend)
906 `(concat "/list_friend.pl?page=%d"
907 (when ,friend (concat "&id=" (mixi-friend-id ,friend)))))
909 (defconst mixi-friend-list-id-regexp
910 "<a href=show_friend\\.pl\\?id=\\([0-9]+\\)")
911 (defconst mixi-friend-list-nick-regexp
912 "<td valign=middle>\\(.+\\)¤µ¤ó([0-9]+)<br />")
914 (defun mixi-get-friends (&rest args)
915 "Get friends of FRIEND."
916 (when (> (length args) 2)
917 (signal 'wrong-number-of-arguments (list 'mixi-get-friends (length args))))
918 (let ((friend (nth 0 args))
919 (range (nth 1 args)))
920 (when (or (not (mixi-friend-p friend)) (mixi-friend-p range))
921 (setq friend (nth 1 args))
922 (setq range (nth 0 args)))
923 (unless (or (null friend) (mixi-friend-p friend))
924 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
925 (let ((ids (mixi-get-matched-items (mixi-friend-list-page friend)
926 mixi-friend-list-id-regexp
928 (nicks (mixi-get-matched-items (mixi-friend-list-page friend)
929 mixi-friend-list-nick-regexp
933 (while (< index (length ids))
934 (setq ret (cons (mixi-make-friend (nth 0 (nth index ids))
935 (nth 0 (nth index nicks))) ret))
940 (defmacro mixi-favorite-list-page ()
941 `(concat "/list_bookmark.pl?page=%d"))
943 (defconst mixi-favorite-list-id-regexp
944 "<td ALIGN=center BGCOLOR=#FDF9F2 width=330><a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">")
945 (defconst mixi-favorite-list-nick-regexp
946 "<td BGCOLOR=#FDF9F2><font COLOR=#996600>̾ Á°</font></td>
947 <td COLSPAN=2 BGCOLOR=#FFFFFF>\\(.+\\)</td></tr>")
949 (defun mixi-get-favorites (&optional range)
951 (let ((ids (mixi-get-matched-items (mixi-favorite-list-page)
952 mixi-favorite-list-id-regexp
954 (nicks (mixi-get-matched-items (mixi-favorite-list-page)
955 mixi-favorite-list-nick-regexp
959 (while (< index (length ids))
960 (setq ret (cons (mixi-make-friend (nth 0 (nth index ids))
961 (nth 0 (nth index nicks))) ret))
966 (defun mixi-make-log (friend time)
967 "Return a log object."
968 (cons 'mixi-log (vector friend time)))
970 (defmacro mixi-log-p (log)
971 `(eq (mixi-object-class ,log) 'mixi-log))
973 (defun mixi-log-friend (log)
974 "Return the friend of LOG."
975 (unless (mixi-log-p log)
976 (signal 'wrong-type-argument (list 'mixi-log-p log)))
979 (defun mixi-log-time (log)
980 "Return the time of LOG."
981 (unless (mixi-log-p log)
982 (signal 'wrong-type-argument (list 'mixi-log-p log)))
985 (defmacro mixi-log-list-page ()
986 `(concat "/show_log.pl"))
988 (defconst mixi-log-list-regexp
989 "\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\) <a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*\\)</a></li>")
991 (defun mixi-get-logs (&optional range)
993 (let ((items (mixi-get-matched-items (mixi-log-list-page)
996 (mapcar (lambda (item)
997 (mixi-make-log (mixi-make-friend (nth 5 item) (nth 6 item))
999 (string-to-number (nth 4 item))
1000 (string-to-number (nth 3 item))
1001 (string-to-number (nth 2 item))
1002 (string-to-number (nth 1 item))
1003 (string-to-number (nth 0 item)))))
1007 (defvar mixi-diary-cache (make-hash-table :test 'equal))
1008 (defun mixi-make-diary (owner id &optional time title content)
1009 "Return a diary object."
1010 (let ((owner (or owner (mixi-make-me))))
1011 (mixi-make-cache (list (mixi-friend-id owner) id)
1012 (cons 'mixi-diary (vector nil owner id time title
1016 (defconst mixi-diary-url-regexp
1017 "/view_diary\\.pl\\?id=\\([0-9]+\\)&owner_id=\\([0-9]+\\)")
1019 (defun mixi-make-diary-from-url (url)
1020 "Return a diary object from URL."
1021 (when (string-match mixi-diary-url-regexp url)
1022 (let ((id (match-string 1 url))
1023 (owner-id (match-string 2 url)))
1024 (mixi-make-diary (mixi-make-friend owner-id) id))))
1026 (defmacro mixi-diary-p (diary)
1027 `(eq (mixi-object-class ,diary) 'mixi-diary))
1029 (defmacro mixi-diary-page (diary)
1030 `(concat "/view_diary.pl?id=" (mixi-diary-id ,diary)
1031 "&owner_id=" (mixi-friend-id (mixi-diary-owner ,diary))))
1033 (defconst mixi-diary-closed-regexp
1034 "<td>ͧ¿Í\\(¤Îͧ¿Í\\)?¤Þ¤Ç¸ø³«¤Î¤¿¤áÆɤळ¤È¤¬½ÐÍè¤Þ¤»¤ó¡£</td></tr>")
1035 (defconst mixi-diary-owner-nick-regexp
1036 "<td WIDTH=490 background=http://img\\.mixi\\.jp/img/bg_w\\.gif><b><font COLOR=#605048>\\(.+?\\)\\(¤µ¤ó\\)?¤ÎÆüµ</font></b></td>")
1037 (defconst mixi-diary-time-regexp
1038 "<td \\(align\\|ALIGN\\)=\"?center\"? \\(rowspan\\|ROWSPAN\\)=\"?[23]\"? \\(nowrap=\"nowrap\"\\|NOWRAP\\) \\(width\\|WIDTH\\)=\"?95\"? bgcolor=\"?#FFD8B0\"?>\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü\\(<br />\\|<br>\\)\\([0-9]+\\):\\([0-9]+\\)</td>")
1039 (defconst mixi-diary-title-regexp
1040 "<td \\(bgcolor\\|BGCOLOR\\)=\"?#FFF4E0\"? width=\"?430\"?> \\([^<]+\\)</td>")
1041 (defconst mixi-diary-content-regexp
1042 "<td \\(class\\|CLASS\\)=\"?h12\"?>\\(.*\\)</td>")
1044 (defun mixi-diary-realize (diary)
1046 ;; FIXME: Check a expiration of cache?
1047 (unless (mixi-object-realize-p diary)
1048 (with-mixi-retrieve (mixi-diary-page diary)
1049 (unless (string-match mixi-diary-closed-regexp buffer)
1050 (if (string-match mixi-diary-owner-nick-regexp buffer)
1051 (mixi-friend-set-nick (mixi-diary-owner diary)
1052 (match-string 1 buffer))
1053 (signal 'error (list 'cannot-find-owner-nick diary)))
1054 (if (string-match mixi-diary-time-regexp buffer)
1055 (mixi-diary-set-time
1056 diary (encode-time 0 (string-to-number (match-string 10 buffer))
1057 (string-to-number (match-string 9 buffer))
1058 (string-to-number (match-string 7 buffer))
1059 (string-to-number (match-string 6 buffer))
1060 (string-to-number (match-string 5 buffer))))
1061 (signal 'error (list 'cannot-find-time diary)))
1062 (if (string-match mixi-diary-title-regexp buffer)
1063 (mixi-diary-set-title diary (match-string 2 buffer))
1064 (signal 'error (list 'cannot-find-title diary)))
1065 (if (string-match mixi-diary-content-regexp buffer)
1066 (mixi-diary-set-content diary (match-string 2 buffer))
1067 (signal 'error (list 'cannot-find-content diary)))))
1068 (mixi-object-touch diary)))
1070 (defun mixi-diary-owner (diary)
1071 "Return the owner of DIARY."
1072 (unless (mixi-diary-p diary)
1073 (signal 'wrong-type-argument (list 'mixi-diary-p diary)))
1074 (aref (cdr diary) 1))
1076 (defun mixi-diary-id (diary)
1077 "Return the id of DIARY."
1078 (unless (mixi-diary-p diary)
1079 (signal 'wrong-type-argument (list 'mixi-diary-p diary)))
1080 (aref (cdr diary) 2))
1082 (defun mixi-diary-time (diary)
1083 "Return the time of DIARY."
1084 (unless (mixi-diary-p diary)
1085 (signal 'wrong-type-argument (list 'mixi-diary-p diary)))
1086 (mixi-diary-realize diary)
1087 (aref (cdr diary) 3))
1089 (defun mixi-diary-title (diary)
1090 "Return the title of DIARY."
1091 (unless (mixi-diary-p diary)
1092 (signal 'wrong-type-argument (list 'mixi-diary-p diary)))
1093 (mixi-diary-realize diary)
1094 (aref (cdr diary) 4))
1096 (defun mixi-diary-content (diary)
1097 "Return the content of DIARY."
1098 (unless (mixi-diary-p diary)
1099 (signal 'wrong-type-argument (list 'mixi-diary-p diary)))
1100 (mixi-diary-realize diary)
1101 (aref (cdr diary) 5))
1103 (defun mixi-diary-set-time (diary time)
1104 "Set the time of DIARY."
1105 (unless (mixi-diary-p diary)
1106 (signal 'wrong-type-argument (list 'mixi-diary-p diary)))
1107 (aset (cdr diary) 3 time))
1109 (defun mixi-diary-set-title (diary title)
1110 "Set the title of DIARY."
1111 (unless (mixi-diary-p diary)
1112 (signal 'wrong-type-argument (list 'mixi-diary-p diary)))
1113 (aset (cdr diary) 4 title))
1115 (defun mixi-diary-set-content (diary content)
1116 "Set the content of DIARY."
1117 (unless (mixi-diary-p diary)
1118 (signal 'wrong-type-argument (list 'mixi-diary-p diary)))
1119 (aset (cdr diary) 5 content))
1121 (defmacro mixi-diary-list-page (&optional friend)
1122 `(concat "/list_diary.pl?page=%d"
1123 (when ,friend (concat "&id=" (mixi-friend-id ,friend)))))
1125 (defconst mixi-diary-list-regexp
1126 "<a href=\"view_diary\\.pl\\?id=\\([0-9]+\\)&owner_id=[0-9]+\">")
1128 (defun mixi-get-diaries (&rest args)
1129 "Get diaries of FRIEND."
1130 (when (> (length args) 2)
1131 (signal 'wrong-number-of-arguments
1132 (list 'mixi-get-diaries (length args))))
1133 (let ((friend (nth 0 args))
1134 (range (nth 1 args)))
1135 (when (or (not (mixi-friend-p friend)) (mixi-friend-p range))
1136 (setq friend (nth 1 args))
1137 (setq range (nth 0 args)))
1138 (unless (or (null friend) (mixi-friend-p friend))
1139 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
1140 (let ((items (mixi-get-matched-items (mixi-diary-list-page friend)
1141 mixi-diary-list-regexp
1143 (mapcar (lambda (item)
1144 (mixi-make-diary friend (nth 0 item)))
1147 (defmacro mixi-new-diary-list-page ()
1148 `(concat "/new_friend_diary.pl?page=%d"))
1150 (defconst mixi-new-diary-list-regexp
1151 "<a class=\"new_link\" href=view_diary\\.pl\\?id=\\([0-9]+\\)&owner_id=\\([0-9]+\\)>")
1153 (defun mixi-get-new-diaries (&optional range)
1155 (let ((items (mixi-get-matched-items (mixi-new-diary-list-page)
1156 mixi-new-diary-list-regexp
1158 (mapcar (lambda (item)
1159 (mixi-make-diary (mixi-make-friend (nth 1 item)) (nth 0 item)))
1162 (defmacro mixi-search-diary-list-page (keyword)
1163 `(concat "/search_diary.pl?page=%d&submit=search&keyword="
1164 (mixi-url-encode-and-quote-percent-string keyword)))
1166 (defconst mixi-search-diary-list-regexp
1167 "<a href=\"view_diary\\.pl\\?id=\\([0-9]+\\)&owner_id=\\([0-9]+\\)\">")
1169 (defun mixi-search-diaries (keyword &optional range)
1170 (let ((items (mixi-get-matched-items (mixi-search-diary-list-page keyword)
1171 mixi-search-diary-list-regexp
1173 (mapcar (lambda (item)
1174 (mixi-make-diary (mixi-make-friend (nth 1 item)) (nth 0 item)))
1177 ;; Community object.
1178 (defvar mixi-community-cache (make-hash-table :test 'equal))
1179 (defun mixi-make-community (id &optional name birthday owner category members
1180 open-level authority description)
1181 "Return a community object."
1182 (mixi-make-cache id (cons 'mixi-community (vector nil id name birthday owner
1184 open-level authority
1186 mixi-community-cache))
1188 (defconst mixi-community-url-regexp
1189 "/view_community\\.pl\\?id=\\([0-9]+\\)")
1191 (defun mixi-make-community-from-url (url)
1192 "Return a community object from URL."
1193 (when (string-match mixi-community-url-regexp url)
1194 (let ((id (match-string 1 url)))
1195 (mixi-make-community id))))
1197 (defmacro mixi-community-p (community)
1198 `(eq (mixi-object-class ,community) 'mixi-community))
1200 (defmacro mixi-community-page (community)
1201 `(concat "/view_community.pl?id=" (mixi-community-id ,community)))
1203 ;; FIXME: Not community specific.
1204 (defconst mixi-community-nodata-regexp
1205 "^¥Ç¡¼¥¿¤¬¤¢¤ê¤Þ¤»¤ó")
1206 (defconst mixi-community-name-regexp
1207 "<td WIDTH=345>\\(.*\\)</td></tr>")
1208 (defconst mixi-community-birthday-regexp
1209 "<td BGCOLOR=#F2DDB7><font COLOR=#996600>³«ÀßÆü</font></td>\n<td>\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü</td>")
1210 ;; FIXME: Care when the owner has seceded.
1211 (defconst mixi-community-owner-regexp
1212 "<td BGCOLOR=#F2DDB7><font COLOR=#996600>´ÉÍý¿Í</font></td>\n<td>\n\n<a href=\"\\(home\\.pl\\|show_friend\\.pl\\?id=\\([0-9]+\\)\\)\">\n\\(.*\\)</a>")
1213 (defconst mixi-community-category-regexp
1214 "<td BGCOLOR=#F2DDB7><font COLOR=#996600>¥«¥Æ¥´¥ê</font></td>\n<td>\\([^<]+\\)</td>")
1215 (defconst mixi-community-members-regexp
1216 "<td BGCOLOR=#F2DDB7><font COLOR=#996600>¥á¥ó¥Ð¡¼¿ô</font></td>\n<td>\\([0-9]+\\)¿Í</td></tr>")
1217 (defconst mixi-community-open-level-regexp
1218 "<td BGCOLOR=#F2DDB7><font COLOR=#996600>»²²Ã¾ò·ï¤È<br>¸ø³«¥ì¥Ù¥ë</font></td>
1219 <td>\\(.+\\)</td></tr>")
1220 (defconst mixi-community-authority-regexp
1221 "<td BGCOLOR=#F2DDB7><font COLOR=#996600>¥È¥Ô¥Ã¥¯ºîÀ®¤Î¸¢¸Â</font></td>\n<td>\\(.+\\)</td></tr>")
1222 (defconst mixi-community-description-regexp
1223 "<td CLASS=h120>\\(.+\\)</td>")
1225 (defun mixi-community-realize (community)
1226 "Realize a COMMUNITY."
1227 ;; FIXME: Check a expiration of cache?
1228 (unless (mixi-object-realize-p community)
1229 (with-mixi-retrieve (mixi-community-page community)
1230 (if (string-match mixi-community-nodata-regexp buffer)
1231 ;; FIXME: Set all members?
1232 (mixi-community-set-name community "¥Ç¡¼¥¿¤¬¤¢¤ê¤Þ¤»¤ó")
1233 (if (string-match mixi-community-name-regexp buffer)
1234 (mixi-community-set-name community (match-string 1 buffer))
1235 (signal 'error (list 'cannot-find-name community)))
1236 (if (string-match mixi-community-birthday-regexp buffer)
1237 (mixi-community-set-birthday
1239 (encode-time 0 0 0 (string-to-number (match-string 3 buffer))
1240 (string-to-number (match-string 2 buffer))
1241 (string-to-number (match-string 1 buffer))))
1242 (signal 'error (list 'cannot-find-birthday community)))
1243 (if (string-match mixi-community-owner-regexp buffer)
1244 (if (string= (match-string 1 buffer) "home.pl")
1245 (mixi-community-set-owner community (mixi-make-me))
1246 (mixi-community-set-owner
1247 community (mixi-make-friend (match-string 2 buffer)
1248 (match-string 3 buffer))))
1249 (signal 'error (list 'cannot-find-owner community)))
1250 (if (string-match mixi-community-category-regexp buffer)
1251 (mixi-community-set-category community (match-string 1 buffer))
1252 (signal 'error (list 'cannot-find-category community)))
1253 (if (string-match mixi-community-members-regexp buffer)
1254 (mixi-community-set-members
1255 community (string-to-number (match-string 1 buffer)))
1256 (signal 'error (list 'cannot-find-members community)))
1257 (if (string-match mixi-community-open-level-regexp buffer)
1258 (mixi-community-set-open-level community (match-string 1 buffer))
1259 (signal 'error (list 'cannot-find-open-level community)))
1260 (if (string-match mixi-community-authority-regexp buffer)
1261 (mixi-community-set-authority community (match-string 1 buffer))
1262 (signal 'error (list 'cannot-find-authority community)))
1263 (if (string-match mixi-community-description-regexp buffer)
1264 (mixi-community-set-description community (match-string 1 buffer))
1265 (signal 'error (list 'cannot-find-description community)))))
1266 (mixi-object-touch community)))
1268 (defun mixi-community-id (community)
1269 "Return the id of COMMUNITY."
1270 (unless (mixi-community-p community)
1271 (signal 'wrong-type-argument (list 'mixi-community-p community)))
1272 (aref (cdr community) 1))
1274 (defun mixi-community-name (community)
1275 "Return the name of COMMUNITY."
1276 (unless (mixi-community-p community)
1277 (signal 'wrong-type-argument (list 'mixi-community-p community)))
1278 (unless (aref (cdr community) 2)
1279 (mixi-community-realize community))
1280 (aref (cdr community) 2))
1282 (defun mixi-community-birthday (community)
1283 "Return the birthday of COMMUNITY."
1284 (unless (mixi-community-p community)
1285 (signal 'wrong-type-argument (list 'mixi-community-p community)))
1286 (mixi-community-realize community)
1287 (aref (cdr community) 3))
1289 (defun mixi-community-owner (community)
1290 "Return the owner of COMMUNITY."
1291 (unless (mixi-community-p community)
1292 (signal 'wrong-type-argument (list 'mixi-community-p community)))
1293 (mixi-community-realize community)
1294 (aref (cdr community) 4))
1296 (defun mixi-community-category (community)
1297 "Return the category of COMMUNITY."
1298 (unless (mixi-community-p community)
1299 (signal 'wrong-type-argument (list 'mixi-community-p community)))
1300 (mixi-community-realize community)
1301 (aref (cdr community) 5))
1303 (defun mixi-community-members (community)
1304 "Return the members of COMMUNITY."
1305 (unless (mixi-community-p community)
1306 (signal 'wrong-type-argument (list 'mixi-community-p community)))
1307 (mixi-community-realize community)
1308 (aref (cdr community) 6))
1310 (defun mixi-community-open-level (community)
1311 "Return the open-level of COMMUNITY."
1312 (unless (mixi-community-p community)
1313 (signal 'wrong-type-argument (list 'mixi-community-p community)))
1314 (mixi-community-realize community)
1315 (aref (cdr community) 7))
1317 (defun mixi-community-authority (community)
1318 "Return the authority of COMMUNITY."
1319 (unless (mixi-community-p community)
1320 (signal 'wrong-type-argument (list 'mixi-community-p community)))
1321 (mixi-community-realize community)
1322 (aref (cdr community) 8))
1324 (defun mixi-community-description (community)
1325 "Return the description of COMMUNITY."
1326 (unless (mixi-community-p community)
1327 (signal 'wrong-type-argument (list 'mixi-community-p community)))
1328 (mixi-community-realize community)
1329 (aref (cdr community) 9))
1331 (defun mixi-community-set-name (community name)
1332 "Set the name of COMMUNITY."
1333 (unless (mixi-community-p community)
1334 (signal 'wrong-type-argument (list 'mixi-community-p community)))
1335 (aset (cdr community) 2 name))
1337 (defun mixi-community-set-birthday (community birthday)
1338 "Set the birthday of COMMUNITY."
1339 (unless (mixi-community-p community)
1340 (signal 'wrong-type-argument (list 'mixi-community-p community)))
1341 (aset (cdr community) 3 birthday))
1343 (defun mixi-community-set-owner (community owner)
1344 "Set the owner of COMMUNITY."
1345 (unless (mixi-community-p community)
1346 (signal 'wrong-type-argument (list 'mixi-community-p community)))
1347 (unless (mixi-friend-p owner)
1348 (signal 'wrong-type-argument (list 'mixi-friend-p owner)))
1349 (aset (cdr community) 4 owner))
1351 (defun mixi-community-set-category (community category)
1352 "Set the category of COMMUNITY."
1353 (unless (mixi-community-p community)
1354 (signal 'wrong-type-argument (list 'mixi-community-p community)))
1355 (aset (cdr community) 5 category))
1357 (defun mixi-community-set-members (community members)
1358 "Set the name of COMMUNITY."
1359 (unless (mixi-community-p community)
1360 (signal 'wrong-type-argument (list 'mixi-community-p community)))
1361 (aset (cdr community) 6 members))
1363 (defun mixi-community-set-open-level (community open-level)
1364 "Set the name of COMMUNITY."
1365 (unless (mixi-community-p community)
1366 (signal 'wrong-type-argument (list 'mixi-community-p community)))
1367 (aset (cdr community) 7 open-level))
1369 (defun mixi-community-set-authority (community authority)
1370 "Set the name of COMMUNITY."
1371 (unless (mixi-community-p community)
1372 (signal 'wrong-type-argument (list 'mixi-community-p community)))
1373 (aset (cdr community) 8 authority))
1375 (defun mixi-community-set-description (community description)
1376 "Set the name of COMMUNITY."
1377 (unless (mixi-community-p community)
1378 (signal 'wrong-type-argument (list 'mixi-community-p community)))
1379 (aset (cdr community) 9 description))
1381 (defmacro mixi-community-list-page (&optional friend)
1382 `(concat "/list_community.pl?page=%d"
1383 (when ,friend (concat "&id=" (mixi-friend-id ,friend)))))
1385 (defconst mixi-community-list-id-regexp
1386 "<a href=view_community\\.pl\\?id=\\([0-9]+\\)")
1387 (defconst mixi-community-list-name-regexp
1388 "<td valign=middle>\\(.+\\)([0-9]+)</td>")
1390 (defun mixi-get-communities (&rest args)
1391 "Get communities of FRIEND."
1392 (when (> (length args) 2)
1393 (signal 'wrong-number-of-arguments
1394 (list 'mixi-get-communities (length args))))
1395 (let ((friend (nth 0 args))
1396 (range (nth 1 args)))
1397 (when (or (not (mixi-friend-p friend)) (mixi-friend-p range))
1398 (setq friend (nth 1 args))
1399 (setq range (nth 0 args)))
1400 (unless (or (null friend) (mixi-friend-p friend))
1401 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
1402 (let ((ids (mixi-get-matched-items (mixi-community-list-page friend)
1403 mixi-community-list-id-regexp
1405 (names (mixi-get-matched-items (mixi-community-list-page friend)
1406 mixi-community-list-name-regexp
1410 (while (< index (length ids))
1411 (setq ret (cons (mixi-make-community (nth 0 (nth index ids))
1412 (nth 0 (nth index names))) ret))
1416 (defmacro mixi-search-community-list-page (keyword)
1417 `(concat "/search_community.pl?page=%d&&sort=date&type=com&submit=main"
1418 "&keyword=" (mixi-url-encode-and-quote-percent-string keyword)
1421 (defconst mixi-search-community-list-regexp
1422 "<td WIDTH=90 VALIGN=top ROWSPAN=4 ALIGN=center background=http://img\\.mixi\\.jp/img/bg_line\\.gif><a href=\"view_community\\.pl\\?id=\\([0-9]+\\)\"><img SRC=\"http://img-c[0-9]+\\.mixi\\.jp/photo/comm/[^.]+\\.jpg\" VSPACE=3 border=0></a></td>
1423 <td NOWRAP WIDTH=90 BGCOLOR=#FDF9F2><font COLOR=#996600>¥³¥ß¥å¥Ë¥Æ¥£Ì¾</font></td>
1424 <td COLSPAN=2 WIDTH=370 BGCOLOR=#FFFFFF>\\([^<]+\\)</td></tr>")
1426 ;; FIXME: Support category.
1427 (defun mixi-search-communities (keyword &optional range)
1428 (let ((items (mixi-get-matched-items (mixi-search-community-list-page
1430 mixi-search-community-list-regexp
1432 (mapcar (lambda (item)
1433 (mixi-make-community (nth 0 item) (nth 1 item)))
1437 (defvar mixi-topic-cache (make-hash-table :test 'equal))
1438 (defun mixi-make-topic (community id &optional time title owner content)
1439 "Return a topic object."
1440 (mixi-make-cache (list (mixi-community-id community) id)
1441 (cons 'mixi-topic (vector nil community id time title owner
1445 (defconst mixi-topic-url-regexp
1446 "/view_bbs\\.pl\\?id=\\([0-9]+\\)\\(&comment_count=[0-9]+\\)?&comm_id=\\([0-9]+\\)")
1448 (defun mixi-make-topic-from-url (url)
1449 "Return a topic object from URL."
1450 (when (string-match mixi-topic-url-regexp url)
1451 (let ((id (match-string 1 url))
1452 (community-id (match-string 3 url)))
1453 (mixi-make-topic (mixi-make-community community-id) id))))
1455 (defmacro mixi-topic-p (topic)
1456 `(eq (mixi-object-class ,topic) 'mixi-topic))
1458 (defmacro mixi-topic-page (topic)
1459 `(concat "/view_bbs.pl?id=" (mixi-topic-id ,topic)
1460 "&comm_id=" (mixi-community-id (mixi-topic-community ,topic))))
1462 (defconst mixi-topic-time-regexp
1463 "<td rowspan=\"3\" width=\"110\" bgcolor=\"#ffd8b0\" align=\"center\" valign=\"top\" nowrap>\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü<br>\\([0-9]+\\):\\([0-9]+\\)</td>")
1464 (defconst mixi-topic-title-regexp
1465 "<td bgcolor=\"#fff4e0\"> \\([^<]+\\)</td>")
1466 (defconst mixi-topic-owner-regexp
1467 "<td bgcolor=\"#fdf9f2\"> <font color=\"#dfb479\"></font> <a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*?\\)\\(¤µ¤ó\\)?</a>")
1468 (defconst mixi-topic-content-regexp
1469 "<table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\"><tr><td class=\"h120\"><table><tr>\\(<td width=\"130\" height=\"140\" align=\"center\" valign=\"middle\"><a href=\"javascript:void(0)\" onClick=\"MM_openBrWindow('show_bbs_picture\\.pl\\?id=[0-9]+&number=[0-9]+','pict','width=680,height=660,toolbar=no,scrollbars=yes,left=5,top=5')\"><img src=\"http://ic[0-9]+\\.mixi\\.jp/[^.]+\\.jpg\" border=\"0\"></a></td>\n\\)*</tr></table>\\(.+\\)</td></tr></table>")
1471 (defun mixi-topic-realize (topic)
1473 ;; FIXME: Check a expiration of cache?
1474 (unless (mixi-object-realize-p topic)
1475 (with-mixi-retrieve (mixi-topic-page topic)
1476 (if (string-match mixi-topic-time-regexp buffer)
1477 (mixi-topic-set-time
1478 topic (encode-time 0 (string-to-number (match-string 5 buffer))
1479 (string-to-number (match-string 4 buffer))
1480 (string-to-number (match-string 3 buffer))
1481 (string-to-number (match-string 2 buffer))
1482 (string-to-number (match-string 1 buffer))))
1483 (signal 'error (list 'cannot-find-time topic)))
1484 (if (string-match mixi-topic-title-regexp buffer)
1485 (mixi-topic-set-title topic (match-string 1 buffer))
1486 (signal 'error (list 'cannot-find-title topic)))
1487 (if (string-match mixi-topic-owner-regexp buffer)
1488 (mixi-topic-set-owner topic
1489 (mixi-make-friend (match-string 1 buffer)
1490 (match-string 2 buffer)))
1491 (signal 'error (list 'cannot-find-owner topic)))
1492 (if (string-match mixi-topic-content-regexp buffer)
1493 (mixi-topic-set-content topic (match-string 2 buffer))
1494 (signal 'error (list 'cannot-find-content topic))))
1495 (mixi-object-touch topic)))
1497 (defun mixi-topic-community (topic)
1498 "Return the community of TOPIC."
1499 (unless (mixi-topic-p topic)
1500 (signal 'wrong-type-argument (list 'mixi-topic-p topic)))
1501 (aref (cdr topic) 1))
1503 (defun mixi-topic-id (topic)
1504 "Return the id of TOPIC."
1505 (unless (mixi-topic-p topic)
1506 (signal 'wrong-type-argument (list 'mixi-topic-p topic)))
1507 (aref (cdr topic) 2))
1509 (defun mixi-topic-time (topic)
1510 "Return the time of TOPIC."
1511 (unless (mixi-topic-p topic)
1512 (signal 'wrong-type-argument (list 'mixi-topic-p topic)))
1513 (mixi-topic-realize topic)
1514 (aref (cdr topic) 3))
1516 (defun mixi-topic-title (topic)
1517 "Return the title of TOPIC."
1518 (unless (mixi-topic-p topic)
1519 (signal 'wrong-type-argument (list 'mixi-topic-p topic)))
1520 (mixi-topic-realize topic)
1521 (aref (cdr topic) 4))
1523 (defun mixi-topic-owner (topic)
1524 "Return the owner of TOPIC."
1525 (unless (mixi-topic-p topic)
1526 (signal 'wrong-type-argument (list 'mixi-topic-p topic)))
1527 (mixi-topic-realize topic)
1528 (aref (cdr topic) 5))
1530 (defun mixi-topic-content (topic)
1531 "Return the content of TOPIC."
1532 (unless (mixi-topic-p topic)
1533 (signal 'wrong-type-argument (list 'mixi-topic-p topic)))
1534 (mixi-topic-realize topic)
1535 (aref (cdr topic) 6))
1537 (defun mixi-topic-set-time (topic time)
1538 "Set the time of TOPIC."
1539 (unless (mixi-topic-p topic)
1540 (signal 'wrong-type-argument (list 'mixi-topic-p topic)))
1541 (aset (cdr topic) 3 time))
1543 (defun mixi-topic-set-title (topic title)
1544 "Set the title of TOPIC."
1545 (unless (mixi-topic-p topic)
1546 (signal 'wrong-type-argument (list 'mixi-topic-p topic)))
1547 (aset (cdr topic) 4 title))
1549 (defun mixi-topic-set-owner (topic owner)
1550 "Set the owner of TOPIC."
1551 (unless (mixi-topic-p topic)
1552 (signal 'wrong-type-argument (list 'mixi-topic-p topic)))
1553 (unless (mixi-friend-p owner)
1554 (signal 'wrong-type-argument (list 'mixi-friend-p owner)))
1555 (aset (cdr topic) 5 owner))
1557 (defun mixi-topic-set-content (topic content)
1558 "Set the content of TOPIC."
1559 (unless (mixi-topic-p topic)
1560 (signal 'wrong-type-argument (list 'mixi-topic-p topic)))
1561 (aset (cdr topic) 6 content))
1564 (defvar mixi-event-cache (make-hash-table :test 'equal))
1565 (defun mixi-make-event (community id &optional time title owner date place
1566 detail limit members)
1567 "Return a event object."
1568 (mixi-make-cache (list (mixi-community-id community) id)
1569 (cons 'mixi-event (vector nil community id time title owner
1570 date place detail limit members))
1573 (defconst mixi-event-url-regexp
1574 "/view_event\\.pl\\?id=\\([0-9]+\\)\\(&comment_count=[0-9]+\\)?&comm_id=\\([0-9]+\\)")
1576 (defun mixi-make-event-from-url (url)
1577 "Return a event object from URL."
1578 (when (string-match mixi-event-url-regexp url)
1579 (let ((id (match-string 1 url))
1580 (community-id (match-string 3 url)))
1581 (mixi-make-event (mixi-make-community community-id) id))))
1583 (defmacro mixi-event-p (event)
1584 `(eq (mixi-object-class ,event) 'mixi-event))
1586 (defmacro mixi-event-page (event)
1587 `(concat "/view_event.pl?id=" (mixi-event-id ,event)
1588 "&comm_id=" (mixi-community-id (mixi-event-community ,event))))
1590 (defconst mixi-event-time-regexp
1591 "<td ROWSPAN=11 BGCOLOR=#FFD8B0 ALIGN=center VALIGN=top WIDTH=110>
1592 \\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü<br>
1593 \\([0-9]+\\):\\([0-9]+\\)</td>")
1594 (defconst mixi-event-title-regexp
1595 "<td bgcolor=#FFF4E0 width=410> \\([^<]+\\)</td>")
1596 (defconst mixi-event-owner-regexp
1597 "<td BGCOLOR=#FDF9F2> <a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*\\)</a>")
1598 (defconst mixi-event-date-regexp
1599 "<td BGCOLOR=#FFFFFF ALIGN=center NOWRAP>³«ºÅÆü»þ</td>
1600 <td BGCOLOR=#FFFFFF>
1603 (defconst mixi-event-place-regexp
1604 "<td BGCOLOR=#FFFFFF ALIGN=center NOWRAP>³«ºÅ¾ì½ê</td>
1605 <td BGCOLOR=#FFFFFF>
1608 (defconst mixi-event-detail-regexp
1609 "<td BGCOLOR=#FFFFFF ALIGN=center NOWRAP>¾ÜºÙ</td>
1610 <td BGCOLOR=#FFFFFF><table BORDER=0 CELLSPACING=0 CELLPADDING=5><tr><td CLASS=h120>\\(.+\\)</td></tr></table></td>")
1611 (defconst mixi-event-limit-regexp
1612 "<td BGCOLOR=#FFFFFF ALIGN=center NOWRAP>Ê罸´ü¸Â</td>
1613 <td BGCOLOR=#FFFFFF> \\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü</td>")
1614 (defconst mixi-event-members-regexp
1615 "<td BGCOLOR=#FFFFFF ALIGN=center NOWRAP>»²²Ã¼Ô</td>
1616 <td BGCOLOR=#FFFFFF>
1617 <table BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%>
1619 <td> \\(.+\\)</td>")
1621 (defun mixi-event-realize (event)
1623 ;; FIXME: Check a expiration of cache?
1624 (unless (mixi-object-realize-p event)
1625 (with-mixi-retrieve (mixi-event-page event)
1626 (if (string-match mixi-event-time-regexp buffer)
1627 (mixi-event-set-time
1628 event (encode-time 0 (string-to-number (match-string 5 buffer))
1629 (string-to-number (match-string 4 buffer))
1630 (string-to-number (match-string 3 buffer))
1631 (string-to-number (match-string 2 buffer))
1632 (string-to-number (match-string 1 buffer))))
1633 (signal 'error (list 'cannot-find-time event)))
1634 (if (string-match mixi-event-title-regexp buffer)
1635 (mixi-event-set-title event (match-string 1 buffer))
1636 (signal 'error (list 'cannot-find-title event)))
1637 (if (string-match mixi-event-owner-regexp buffer)
1638 (mixi-event-set-owner event
1639 (mixi-make-friend (match-string 1 buffer)
1640 (match-string 2 buffer)))
1641 (signal 'error (list 'cannot-find-owner event)))
1642 (if (string-match mixi-event-date-regexp buffer)
1643 (mixi-event-set-date event (match-string 1 buffer))
1644 (signal 'error (list 'cannot-find-date event)))
1645 (if (string-match mixi-event-place-regexp buffer)
1646 (mixi-event-set-place event (match-string 1 buffer))
1647 (signal 'error (list 'cannot-find-place event)))
1648 (if (string-match mixi-event-detail-regexp buffer)
1649 (mixi-event-set-detail event (match-string 1 buffer))
1650 (signal 'error (list 'cannot-find-detail event)))
1651 (when (string-match mixi-event-limit-regexp buffer)
1652 (mixi-event-set-limit
1653 event (encode-time 0 0 0 (string-to-number (match-string 3 buffer))
1654 (string-to-number (match-string 2 buffer))
1655 (string-to-number (match-string 1 buffer)))))
1656 (if (string-match mixi-event-members-regexp buffer)
1657 (mixi-event-set-members event (match-string 1 buffer))
1658 (signal 'error (list 'cannot-find-members event))))
1659 (mixi-object-touch event)))
1661 (defun mixi-event-community (event)
1662 "Return the community of EVENT."
1663 (unless (mixi-event-p event)
1664 (signal 'wrong-type-argument (list 'mixi-event-p event)))
1665 (aref (cdr event) 1))
1667 (defun mixi-event-id (event)
1668 "Return the id of EVENT."
1669 (unless (mixi-event-p event)
1670 (signal 'wrong-type-argument (list 'mixi-event-p event)))
1671 (aref (cdr event) 2))
1673 (defun mixi-event-time (event)
1674 "Return the time of EVENT."
1675 (unless (mixi-event-p event)
1676 (signal 'wrong-type-argument (list 'mixi-event-p event)))
1677 (mixi-event-realize event)
1678 (aref (cdr event) 3))
1680 (defun mixi-event-title (event)
1681 "Return the title of EVENT."
1682 (unless (mixi-event-p event)
1683 (signal 'wrong-type-argument (list 'mixi-event-p event)))
1684 (mixi-event-realize event)
1685 (aref (cdr event) 4))
1687 (defun mixi-event-owner (event)
1688 "Return the owner of EVENT."
1689 (unless (mixi-event-p event)
1690 (signal 'wrong-type-argument (list 'mixi-event-p event)))
1691 (mixi-event-realize event)
1692 (aref (cdr event) 5))
1694 (defun mixi-event-date (event)
1695 "Return the date of EVENT."
1696 (unless (mixi-event-p event)
1697 (signal 'wrong-type-argument (list 'mixi-event-p event)))
1698 (mixi-event-realize event)
1699 (aref (cdr event) 6))
1701 (defun mixi-event-place (event)
1702 "Return the place of EVENT."
1703 (unless (mixi-event-p event)
1704 (signal 'wrong-type-argument (list 'mixi-event-p event)))
1705 (mixi-event-realize event)
1706 (aref (cdr event) 7))
1708 (defun mixi-event-detail (event)
1709 "Return the detail of EVENT."
1710 (unless (mixi-event-p event)
1711 (signal 'wrong-type-argument (list 'mixi-event-p event)))
1712 (mixi-event-realize event)
1713 (aref (cdr event) 8))
1715 (defun mixi-event-limit (event)
1716 "Return the limit of EVENT."
1717 (unless (mixi-event-p event)
1718 (signal 'wrong-type-argument (list 'mixi-event-p event)))
1719 (mixi-event-realize event)
1720 (aref (cdr event) 9))
1722 (defun mixi-event-members (event)
1723 "Return the members of EVENT."
1724 (unless (mixi-event-p event)
1725 (signal 'wrong-type-argument (list 'mixi-event-p event)))
1726 (mixi-event-realize event)
1727 (aref (cdr event) 10))
1729 (defun mixi-event-set-time (event time)
1730 "Set the time of EVENT."
1731 (unless (mixi-event-p event)
1732 (signal 'wrong-type-argument (list 'mixi-event-p event)))
1733 (aset (cdr event) 3 time))
1735 (defun mixi-event-set-title (event title)
1736 "Set the title of EVENT."
1737 (unless (mixi-event-p event)
1738 (signal 'wrong-type-argument (list 'mixi-event-p event)))
1739 (aset (cdr event) 4 title))
1741 (defun mixi-event-set-owner (event owner)
1742 "Set the owner of EVENT."
1743 (unless (mixi-event-p event)
1744 (signal 'wrong-type-argument (list 'mixi-event-p event)))
1745 (unless (mixi-friend-p owner)
1746 (signal 'wrong-type-argument (list 'mixi-friend-p owner)))
1747 (aset (cdr event) 5 owner))
1749 (defun mixi-event-set-date (event date)
1750 "Set the date of EVENT."
1751 (unless (mixi-event-p event)
1752 (signal 'wrong-type-argument (list 'mixi-event-p event)))
1753 (aset (cdr event) 6 date))
1755 (defun mixi-event-set-place (event place)
1756 "Set the place of EVENT."
1757 (unless (mixi-event-p event)
1758 (signal 'wrong-type-argument (list 'mixi-event-p event)))
1759 (aset (cdr event) 7 place))
1761 (defun mixi-event-set-detail (event detail)
1762 "Set the detail of EVENT."
1763 (unless (mixi-event-p event)
1764 (signal 'wrong-type-argument (list 'mixi-event-p event)))
1765 (aset (cdr event) 8 detail))
1767 (defun mixi-event-set-limit (event limit)
1768 "Set the limit of EVENT."
1769 (unless (mixi-event-p event)
1770 (signal 'wrong-type-argument (list 'mixi-event-p event)))
1771 (aset (cdr event) 9 limit))
1773 (defun mixi-event-set-members (event members)
1774 "Set the members of EVENT."
1775 (unless (mixi-event-p event)
1776 (signal 'wrong-type-argument (list 'mixi-event-p event)))
1777 (aset (cdr event) 10 members))
1780 (defalias 'mixi-bbs-owner 'mixi-object-owner)
1781 (defalias 'mixi-bbs-id 'mixi-object-id)
1782 (defalias 'mixi-bbs-time 'mixi-object-time)
1783 (defalias 'mixi-bbs-title 'mixi-object-title)
1784 (defalias 'mixi-bbs-content 'mixi-object-content)
1786 (defmacro mixi-bbs-list-page (community)
1787 `(concat "/list_bbs.pl?page=%d"
1788 "&id=" (mixi-community-id ,community)))
1790 (defconst mixi-bbs-list-regexp
1791 "<a href=view_\\(bbs\\|event\\)\\.pl\\?id=\\([0-9]+\\)")
1793 (defun mixi-get-bbses (community &optional range)
1794 "Get bbese of COMMUNITY."
1795 (unless (mixi-community-p community)
1796 (signal 'wrong-type-argument (list 'mixi-community-p community)))
1797 (let ((items (mixi-get-matched-items (mixi-bbs-list-page community)
1798 mixi-bbs-list-regexp
1800 (mapcar (lambda (item)
1801 (let ((name (nth 0 item)))
1802 (when (string= name "bbs")
1803 (setq name "topic"))
1804 (let ((func (intern (concat "mixi-make-" name))))
1805 (funcall func community (nth 1 item)))))
1808 (defmacro mixi-new-bbs-list-page ()
1809 `(concat "/new_bbs.pl?page=%d"))
1811 (defconst mixi-new-bbs-list-regexp
1812 "<a href=\"view_\\(bbs\\|event\\)\\.pl\\?id=\\([0-9]+\\)&comment_count=[0-9]+&comm_id=\\([0-9]+\\)\" class=\"new_link\">")
1814 (defun mixi-get-new-bbses (&optional range)
1816 (let ((items (mixi-get-matched-items (mixi-new-bbs-list-page)
1817 mixi-new-bbs-list-regexp
1819 (mapcar (lambda (item)
1820 (let ((name (nth 0 item)))
1821 (when (string= name "bbs")
1822 (setq name "topic"))
1823 (let ((func (intern (concat "mixi-make-" name))))
1824 (funcall func (mixi-make-community (nth 2 item))
1828 (defmacro mixi-search-bbs-list-page (keyword)
1829 `(concat "/search_topic.pl?page=%d&type=top&submit=search"
1830 "&keyword=" (mixi-url-encode-and-quote-percent-string keyword)
1831 "&community_id=0&category_id=0"))
1833 (defconst mixi-search-bbs-list-regexp
1834 "<a href=\"view_\\(bbs\\|event\\)\\.pl\\?id=\\([0-9]+\\)&comm_id=\\([0-9]+\\)\"><img src=http://img\\.mixi\\.jp/img/shbtn\\.gif ALT=¾ÜºÙ¤ò¸«¤ë BORDER=0 WIDTH=104 HEIGHT=19></a>")
1836 ;; FIXME: Support community and category.
1837 (defun mixi-search-bbses (keyword &optional range)
1838 (let ((items (mixi-get-matched-items (mixi-search-bbs-list-page keyword)
1839 mixi-search-bbs-list-regexp
1841 (mapcar (lambda (item)
1842 (let ((name (nth 0 item)))
1843 (when (string= name "bbs")
1844 (setq name "topic"))
1845 (let ((func (intern (concat "mixi-make-" name))))
1846 (funcall func (mixi-make-community (nth 2 item))
1851 (defun mixi-make-comment (parent owner time content)
1852 "Return a comment object."
1853 (cons 'mixi-comment (vector parent owner time content)))
1855 (defmacro mixi-comment-p (comment)
1856 `(eq (mixi-object-class ,comment) 'mixi-comment))
1858 (defun mixi-comment-parent (comment)
1859 "Return the parent of COMMENT."
1860 (unless (mixi-comment-p comment)
1861 (signal 'wrong-type-argument (list 'mixi-comment-p comment)))
1862 (aref (cdr comment) 0))
1864 (defun mixi-comment-owner (comment)
1865 "Return the owner of COMMENT."
1866 (unless (mixi-comment-p comment)
1867 (signal 'wrong-type-argument (list 'mixi-comment-p comment)))
1868 (aref (cdr comment) 1))
1870 (defun mixi-comment-time (comment)
1871 "Return the time of COMMENT."
1872 (unless (mixi-comment-p comment)
1873 (signal 'wrong-type-argument (list 'mixi-comment-p comment)))
1874 (aref (cdr comment) 2))
1876 (defun mixi-comment-content (comment)
1877 "Return the content of COMMENT."
1878 (unless (mixi-comment-p comment)
1879 (signal 'wrong-type-argument (list 'mixi-comment-p comment)))
1880 (aref (cdr comment) 3))
1882 (defun mixi-diary-comment-list-page (diary)
1883 (concat "/view_diary.pl?full=1"
1884 "&id=" (mixi-diary-id diary)
1885 "&owner_id=" (mixi-friend-id (mixi-diary-owner diary))))
1887 ;; FIXME: Split regexp to time, owner(id and nick) and contents.
1888 (defconst mixi-diary-comment-list-regexp
1889 "<td rowspan=\"2\" align=\"center\" width=\"95\" bgcolor=\"#f2ddb7\" nowrap>
1890 \\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü<br>\\([0-9]+\\):\\([0-9]+\\)\\(<br>
1891 <input type=checkbox name=comment_id value=\".+\">
1894 <td ALIGN=center BGCOLOR=#FDF9F2 WIDTH=430>
1895 <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"410\">
1898 <a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*\\)</a>
1900 \\(<font color=\"#f2ddb7\">|</font> <a href=[^>]+>ºï½ü</a>
1907 <!-- ËÜʸ : start -->
1909 <td bgcolor=\"#ffffff\">
1910 <table BORDER=0 CELLSPACING=0 CELLPADDING=[35] WIDTH=410>
1914 </td></tr></table>")
1916 (defun mixi-topic-comment-list-page (topic)
1917 (concat "/view_bbs.pl?page=all"
1918 "&id=" (mixi-topic-id topic)
1919 "&comm_id=" (mixi-community-id (mixi-topic-community topic))))
1921 ;; FIXME: Split regexp to time, owner(id and nick) and contents.
1922 (defconst mixi-topic-comment-list-regexp
1923 "<tr valign=\"top\">
1924 <td rowspan=\"2\" width=\"110\" bgcolor=\"#f2ddb7\" align=\"center\" nowrap>
1925 \\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü<br>
1926 \\([0-9]+\\):\\([0-9]+\\)<br>
1927 \\(<input type=\"checkbox\" name=\"comment_id\" value=\".+\">
1929 <td bgcolor=\"#fdf9f2\"> <font color=\"#f8a448\">
1930 <b>[^<]+</b>:</font>
1932 \\|\\) *<a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*\\)</a>
1936 \\|<font color=\"#f2ddb7\">| </font><a href=\"delete_bbs_comment\\.pl\\?id=[0-9]+&comm_id=[0-9]+&comment_id=[0-9]+\">ºï½ü</a>
1940 <td bgcolor=\"#ffffff\" align=\"center\">
1941 <table border=\"0\" cellspacing=\"0\" cellpadding=\"5\" width=\"500\">
1952 (defun mixi-event-comment-list-page (event)
1953 (concat "/view_event.pl?page=all"
1954 "&id=" (mixi-event-id event)
1955 "&comm_id=" (mixi-community-id (mixi-event-community event))))
1957 ;; FIXME: Split regexp to time, owner(id and nick) and contents.
1958 (defconst mixi-event-comment-list-regexp
1960 <td ROWSPAN=2 ALIGN=center BGCOLOR=#F2DDB7 WIDTH=110>
1961 \\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü<br>
1962 \\([0-9]+\\):\\([0-9]+\\)<br>
1964 \\(<td BGCOLOR=#FDF9F2>\\)
1965 <font COLOR=#F8A448><b>[^<]+</b> :</font>
1966 <a HREF=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*\\)</a>
1971 <td ALIGN=center BGCOLOR=#FFFFFF>
1972 <table BORDER=0 CELLSPACING=0 CELLPADDING=5 WIDTH=500>
1973 <tr><td CLASS=h120>\\(.+\\)</td></tr>
1978 (defun mixi-get-comments (parent &optional range)
1979 "Get comments of PARENT."
1980 (unless (mixi-object-p parent)
1981 (signal 'wrong-type-argument (list 'mixi-object-p parent)))
1982 (let* ((name (mixi-object-name parent))
1983 (list-page (intern (concat mixi-object-prefix name
1984 "-comment-list-page")))
1985 (regexp (eval (intern (concat mixi-object-prefix name
1986 "-comment-list-regexp")))))
1987 (let ((items (mixi-get-matched-items
1988 (funcall list-page parent) regexp)))
1991 (mapc (lambda (item)
1992 (when (and (numberp range)
1993 (>= (length list) range))
1995 (setq list (cons item list)))
1997 (setq items (reverse list)))
1998 (mapcar (lambda (item)
1999 (mixi-make-comment parent (mixi-make-friend
2000 (nth 7 item) (nth 8 item))
2003 (string-to-number (nth 4 item))
2004 (string-to-number (nth 3 item))
2005 (string-to-number (nth 2 item))
2006 (string-to-number (nth 1 item))
2007 (string-to-number (nth 0 item)))
2011 (defmacro mixi-new-comment-list-page ()
2012 `(concat "/new_comment.pl?page=%d"))
2014 (defconst mixi-new-comment-list-regexp
2015 "<a href=\"view_diary\\.pl\\?id=\\([0-9]+\\)&owner_id=\\([0-9]+\\)&comment_count=[0-9]+\" class=\"new_link\">")
2017 (defun mixi-get-new-comments (&optional range)
2019 (let ((items (mixi-get-matched-items (mixi-new-comment-list-page)
2020 mixi-new-comment-list-regexp
2022 (mapcar (lambda (item)
2023 (mixi-make-diary (mixi-make-friend (nth 1 item)) (nth 0 item)))
2027 (defconst mixi-message-box-list '(inbox outbox savebox thrash)) ; thrash?
2029 (defmacro mixi-message-box-p (box)
2030 `(when (memq ,box mixi-message-box-list)
2033 (defun mixi-message-box-name (box)
2034 "Return the name of BOX."
2035 (unless (mixi-message-box-p box)
2036 (signal 'wrong-type-argument (list 'mixi-message-box-p box)))
2039 (defvar mixi-message-cache (make-hash-table :test 'equal))
2040 (defun mixi-make-message (id box &optional owner title time content)
2041 "Return a message object."
2042 (mixi-make-cache (list id box)
2043 (cons 'mixi-message (vector nil id box owner title time
2045 mixi-message-cache))
2047 (defconst mixi-message-url-regexp
2048 "/view_message\\.pl\\?id=\\([a-z0-9]+\\)&box=\\([a-z]+\\)")
2050 (defun mixi-make-message-from-url (url)
2051 "Return a message object from URL."
2052 (when (string-match mixi-message-url-regexp url)
2053 (let ((id (match-string 1 url))
2054 (box (match-string 2 url)))
2055 (mixi-make-message id box))))
2057 (defmacro mixi-message-p (message)
2058 `(eq (mixi-object-class ,message) 'mixi-message))
2060 (defmacro mixi-message-page (message)
2061 `(concat "/view_message.pl?id=" (mixi-message-id ,message)
2062 "&box=" (mixi-message-box ,message)))
2064 (defconst mixi-message-owner-regexp
2065 "<font COLOR=#996600>\\(º¹½Ð¿Í\\|°¸ Àè\\)</font> : <a HREF=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*\\)\\(</a>\\|</td>\\)")
2066 (defconst mixi-message-title-regexp
2067 "<font COLOR=#996600>·ï\\(¡¡\\| \\)̾</font> : \\(.+\\)\n?</td>")
2068 (defconst mixi-message-time-regexp
2069 "<font COLOR=#996600>Æü\\(¡¡\\| \\)ÉÕ</font> : \\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\)»þ\\([0-9]+\\)ʬ ")
2070 (defconst mixi-message-content-regexp
2071 "<tr><td CLASS=h120>\\(.+\\)</td></tr>")
2073 (defun mixi-message-realize (message)
2074 "Realize a MESSAGE."
2075 (unless (mixi-object-realize-p message)
2076 (with-mixi-retrieve (mixi-message-page message)
2077 (if (string-match mixi-message-owner-regexp buffer)
2078 (mixi-message-set-owner message
2079 (mixi-make-friend (match-string 2 buffer)
2080 (match-string 3 buffer)))
2081 (signal 'error (list 'cannot-find-owner message)))
2082 (if (string-match mixi-message-title-regexp buffer)
2083 (mixi-message-set-title message (match-string 2 buffer))
2084 (signal 'error (list 'cannot-find-title message)))
2085 (if (string-match mixi-message-time-regexp buffer)
2086 (mixi-message-set-time
2087 message (encode-time 0 (string-to-number (match-string 6 buffer))
2088 (string-to-number (match-string 5 buffer))
2089 (string-to-number (match-string 4 buffer))
2090 (string-to-number (match-string 3 buffer))
2091 (string-to-number (match-string 2 buffer))))
2092 (signal 'error (list 'cannot-find-time message)))
2093 (if (string-match mixi-message-content-regexp buffer)
2094 (mixi-message-set-content message (match-string 1 buffer))
2095 (signal 'error (list 'cannot-find-content message))))
2096 (mixi-object-touch message)))
2098 (defun mixi-message-id (message)
2099 "Return the id of MESSAGE."
2100 (unless (mixi-message-p message)
2101 (signal 'wrong-type-argument (list 'mixi-message-p message)))
2102 (aref (cdr message) 1))
2104 (defun mixi-message-box (message)
2105 "Return the box of MESSAGE."
2106 (unless (mixi-message-p message)
2107 (signal 'wrong-type-argument (list 'mixi-message-p message)))
2108 (aref (cdr message) 2))
2110 (defun mixi-message-owner (message)
2111 "Return the owner of MESSAGE."
2112 (unless (mixi-message-p message)
2113 (signal 'wrong-type-argument (list 'mixi-message-p message)))
2114 (mixi-message-realize message)
2115 (aref (cdr message) 3))
2117 (defun mixi-message-title (message)
2118 "Return the title of MESSAGE."
2119 (unless (mixi-message-p message)
2120 (signal 'wrong-type-argument (list 'mixi-message-p message)))
2121 (mixi-message-realize message)
2122 (aref (cdr message) 4))
2124 (defun mixi-message-time (message)
2125 "Return the date of MESSAGE."
2126 (unless (mixi-message-p message)
2127 (signal 'wrong-type-argument (list 'mixi-message-p message)))
2128 (mixi-message-realize message)
2129 (aref (cdr message) 5))
2131 (defun mixi-message-content (message)
2132 "Return the content of MESSAGE."
2133 (unless (mixi-message-p message)
2134 (signal 'wrong-type-argument (list 'mixi-message-p message)))
2135 (mixi-message-realize message)
2136 (aref (cdr message) 6))
2138 (defun mixi-message-set-owner (message owner)
2139 "Set the owner of MESSAGE."
2140 (unless (mixi-message-p message)
2141 (signal 'wrong-type-argument (list 'mixi-message-p message)))
2142 (aset (cdr message) 3 owner))
2144 (defun mixi-message-set-title (message title)
2145 "Set the title of MESSAGE."
2146 (unless (mixi-message-p message)
2147 (signal 'wrong-type-argument (list 'mixi-message-p message)))
2148 (aset (cdr message) 4 title))
2150 (defun mixi-message-set-time (message time)
2151 "Set the date of MESSAGE."
2152 (unless (mixi-message-p message)
2153 (signal 'wrong-type-argument (list 'mixi-message-p message)))
2154 (aset (cdr message) 5 time))
2156 (defun mixi-message-set-content (message content)
2157 "Set the content of MESSAGE."
2158 (unless (mixi-message-p message)
2159 (signal 'wrong-type-argument (list 'mixi-message-p message)))
2160 (aset (cdr message) 6 content))
2162 (defmacro mixi-message-list-page (&optional box)
2163 `(concat "/list_message.pl?page=%d"
2164 (when ,box (concat "&box=" ,box))))
2166 (defconst mixi-message-list-regexp
2167 "<td><a HREF=\"view_message\\.pl\\?id=\\(.+\\)&box=\\(.+\\)\">")
2169 (defun mixi-get-messages (&rest args)
2171 (when (> (length args) 2)
2172 (signal 'wrong-number-of-arguments
2173 (list 'mixi-get-messages (length args))))
2174 (let ((box (nth 0 args))
2175 (range (nth 1 args)))
2176 (when (or (not (mixi-message-box-p box))
2177 (mixi-message-box-p range))
2178 (setq box (nth 1 args))
2179 (setq range (nth 0 args)))
2180 (let ((items (mixi-get-matched-items
2181 (mixi-message-list-page
2182 (when box (mixi-message-box-name box)))
2183 mixi-message-list-regexp
2185 (mapcar (lambda (item)
2186 (mixi-make-message (nth 0 item) (nth 1 item)))
2189 ;; Introduction object.
2190 (defun mixi-make-introduction (parent owner content)
2191 "Return a introduction object."
2192 (cons 'mixi-introduction (vector parent owner content)))
2194 (defmacro mixi-introduction-p (introduction)
2195 `(eq (mixi-object-class ,introduction) 'mixi-introduction))
2197 (defun mixi-introduction-parent (introduction)
2198 "Return the parent of INTRODUCTION."
2199 (unless (mixi-introduction-p introduction)
2200 (signal 'wrong-type-argument (list 'mixi-introduction-p introduction)))
2201 (aref (cdr introduction) 0))
2203 (defun mixi-introduction-owner (introduction)
2204 "Return the owner of INTRODUCTION."
2205 (unless (mixi-introduction-p introduction)
2206 (signal 'wrong-type-argument (list 'mixi-introduction-p introduction)))
2207 (aref (cdr introduction) 1))
2209 (defun mixi-introduction-content (introduction)
2210 "Return the content of INTRODUCTION."
2211 (unless (mixi-introduction-p introduction)
2212 (signal 'wrong-type-argument (list 'mixi-introduction-p introduction)))
2213 (aref (cdr introduction) 3))
2215 (defmacro mixi-introduction-list-page (&optional friend)
2216 `(concat "/show_intro.pl?page=%d"
2217 (when ,friend (concat "&id=" (mixi-friend-id ,friend)))))
2219 (defconst mixi-introduction-list-regexp
2220 "<tr bgcolor=#FFFFFF>
2221 <td WIDTH=150 background=http://img\\.mixi\\.jp/img/bg_line\\.gif align=\"center\"><a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\"><img src=\".+\" border=0><br>
2228 \\(\\(.\\|\n<br>\\)+\\)\\|
2229 \\(\\(.\\|\n<br>\\)+\\)\\)
2236 (defconst mixi-my-introduction-list-regexp
2237 "<tr bgcolor=#FFFFFF>
2238 <td WIDTH=150 background=http://img\\.mixi\\.jp/img/bg_line\\.gif align=\"center\"><a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\"><img src=\".+\" border=0><br>
2246 \\(\\(.\\|\n<br>\\)+\\)\\|
2247 \\(\\(.\\|\n<br>\\)+\\)\\)
2251 <a href=\"edit_intro\\.pl\\?id=\\1&type=edit\">¤³¤Îͧ¿Í¤ò¾Ò²ð¤¹¤ë</a>
2255 <a href=\"delete_intro\\.pl\\?id=\\1\">ºï½ü</a>
2260 (defun mixi-get-introductions (&rest args)
2261 "Get introductions."
2262 (when (> (length args) 2)
2263 (signal 'wrong-number-of-arguments
2264 (list 'mixi-get-introduction (length args))))
2265 (let ((friend (nth 0 args))
2266 (range (nth 1 args)))
2267 (when (or (not (mixi-friend-p friend)) (mixi-friend-p range))
2268 (setq friend (nth 1 args))
2269 (setq range (nth 0 args)))
2270 (unless (or (null friend) (mixi-friend-p friend))
2271 (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
2272 (let* ((regexp (if friend mixi-introduction-list-regexp
2273 mixi-my-introduction-list-regexp))
2274 (items (mixi-get-matched-items (mixi-introduction-list-page friend)
2277 (mapcar (lambda (item)
2278 (mixi-make-introduction (or friend (mixi-make-me))
2279 (mixi-make-friend (nth 0 item)
2286 ;;; mixi.el ends here