-;; mixi.el --- API libraries for accessing to mixi
+;; mixi.el --- API libraries for accessing to mixi -*- coding: euc-jp -*-
;; Copyright (C) 2005,2006 OHASHI Akira
;; (buffer (get-buffer-create "*temp*"))
;; (format "%Y/%m/%d %H:%M"))
;; (pop-to-buffer buffer)
-;; (mapc (lambda (diary)
-;; (let ((subject (mixi-diary-title diary))
-;; (from (mixi-friend-nick (mixi-diary-owner diary)))
-;; (date (format-time-string format (mixi-diary-time diary)))
-;; (body (mixi-remove-markup (mixi-diary-content diary))))
-;; (insert "From: " from "\n"
-;; "Subject: " subject "\n"
-;; "Date: " date "\n\n"
-;; body "\n\n")))
-;; (mixi-get-new-diaries range))
+;; (let ((diaries (mixi-get-new-diaries range)))
+;; (while diaries
+;; (let* ((diary (car diaries))
+;; (subject (mixi-diary-title diary))
+;; (from (mixi-friend-nick (mixi-diary-owner diary)))
+;; (date (format-time-string format (mixi-diary-time diary)))
+;; (body (mixi-remove-markup (mixi-diary-content diary))))
+;; (insert "From: " from "\n"
+;; "Subject: " subject "\n"
+;; "Date: " date "\n\n"
+;; body "\n\n"))
+;; (setq diaries (cdr diaries))))
;; (set-buffer-modified-p nil)
;; (setq buffer-read-only t)
;; (goto-char (point-min)))
;; (buffer (get-buffer-create "*temp*"))
;; (format "%Y/%m/%d %H:%M"))
;; (pop-to-buffer buffer)
-;; (mapc (lambda (diary)
-;; (let ((subject (mixi-diary-title diary))
-;; (from (mixi-friend-nick (mixi-diary-owner diary)))
-;; (date (format-time-string format (mixi-diary-time diary)))
-;; (body (mixi-remove-markup (mixi-diary-content diary))))
-;; (insert "From: " from "\n"
-;; "Subject: " subject "\n"
-;; "Date: " date "\n\n"
-;; body "\n\n")
-;; (mapc (lambda (comment)
-;; (let ((from (mixi-friend-nick
-;; (mixi-comment-owner comment)))
-;; (subject (concat "Re: " subject))
-;; (date (format-time-string
-;; format (mixi-comment-time comment)))
-;; (body (mixi-remove-markup
-;; (mixi-comment-content comment))))
-;; (insert "From: " from "\n"
-;; "Subject: " subject "\n"
-;; "Date: " date "\n\n"
-;; body "\n\n")))
-;; (mixi-get-comments diary range))))
-;; (mixi-get-new-diaries range))
+;; (let ((diaries (mixi-get-new-diaries range)))
+;; (while diaries
+;; (let* ((diary (car diaries))
+;; (subject (mixi-diary-title diary))
+;; (from (mixi-friend-nick (mixi-diary-owner diary)))
+;; (date (format-time-string format (mixi-diary-time diary)))
+;; (body (mixi-remove-markup (mixi-diary-content diary))))
+;; (insert "From: " from "\n"
+;; "Subject: " subject "\n"
+;; "Date: " date "\n\n"
+;; body "\n\n")
+;; (let ((comments (mixi-get-comments diary range)))
+;; (while comments
+;; (let* ((comment (car comments))
+;; (from (mixi-friend-nick (mixi-comment-owner comment)))
+;; (subject (concat "Re: " subject))
+;; (date (format-time-string format
+;; (mixi-comment-time comment)))
+;; (body (mixi-remove-markup (mixi-comment-content comment))))
+;; (insert "From: " from "\n"
+;; "Subject: " subject "\n"
+;; "Date: " date "\n\n"
+;; body "\n\n"))
+;; (setq comments (cdr comments)))))
+;; (setq diaries (cdr diaries))))
;; (set-buffer-modified-p nil)
;; (setq buffer-read-only t)
;; (goto-char (point-min)))
(mixi-curl-retrieve url nil (reverse form-data))))
(defconst mixi-my-id-regexp
- "<a href=\"add_diary\\.pl\\?id=\\([0-9]+\\)")
+ "<a href=\"show_profile\\.pl\\?id=\\([0-9]+\\)")
(defun mixi-login (&optional email password)
"Login to mixi."
(read-from-minibuffer (mixi-message "Login Email: "))))
(password (or password mixi-default-password
(read-passwd (mixi-message "Login Password: ")))))
- (let ((url "/login.pl"))
- (when mixi-login-use-ssl
- (setq url (concat "https://mixi.jp" url)))
+ (let ((url (mixi-expand-url "/login.pl")))
+ (when (and mixi-login-use-ssl (string-match "^http:" url))
+ (setq url (replace-match "https:" nil nil url)))
(let ((buffer (mixi-retrieve url
(concat "email=" email
"&password=" password
(unless (file-directory-p cache-directory)
(make-directory cache-directory t))
(let ((caches (apropos-internal mixi-cache-regexp 'boundp)))
- (mapc (lambda (symbol)
- (with-temp-file (expand-file-name
- (substring (symbol-name symbol)
- (length mixi-object-prefix))
- cache-directory)
- (let ((coding-system-for-write mixi-coding-system)
- (cache (symbol-value symbol)))
- (insert "#s(hash-table size "
- (number-to-string (hash-table-count cache))
- " test equal data (\n")
- (maphash
- (lambda (key value)
- (let (print-level print-length)
- (insert (prin1-to-string key) " "
- (prin1-to-string value) "\n")))
- cache))
- (insert "))")))
- caches))))
+ (while caches
+ (with-temp-file (expand-file-name
+ (substring (symbol-name (car caches))
+ (length mixi-object-prefix))
+ cache-directory)
+ (let ((coding-system-for-write mixi-coding-system)
+ (cache (symbol-value (car caches))))
+ (insert "#s(hash-table size "
+ (number-to-string (hash-table-count cache))
+ " test equal data (\n")
+ (maphash
+ (lambda (key value)
+ (let (print-level print-length)
+ (insert (prin1-to-string key) " "
+ (prin1-to-string value) "\n")))
+ cache))
+ (insert "))"))
+ (setq caches (cdr caches))))))
;; stolen (and modified) from lsdb.el
(defun mixi-read-cache (&optional marker)
;; FIXME: Load friend and community first.
(let ((files (directory-files cache-directory t
mixi-cache-file-regexp)))
- (mapc (lambda (file)
- (let ((buffer (find-file-noselect file)))
- (unwind-protect
- (save-excursion
- (set-buffer buffer)
- (goto-char (point-min))
- (re-search-forward "^#s(")
- (goto-char (match-beginning 0))
- (mixi-read-cache (point-marker)))
- (kill-buffer buffer))))
- files)))))
+ (while files
+ (let ((buffer (find-file-noselect (car files))))
+ (unwind-protect
+ (save-excursion
+ (set-buffer buffer)
+ (goto-char (point-min))
+ (re-search-forward "^#s(")
+ (goto-char (match-beginning 0))
+ (mixi-read-cache (point-marker)))
+ (kill-buffer buffer)))
+ (setq files (cdr files)))))))
;; Friend object.
(defvar mixi-friend-cache (make-hash-table :test 'equal))
"Return a my object."
(unless mixi-me
(with-mixi-retrieve "/home.pl"
- (if (re-search-forward mixi-my-id-regexp)
+ (if (re-search-forward mixi-my-id-regexp nil t)
(setq mixi-me (mixi-make-friend (match-string 1)))
(signal 'error (list 'who-am-i)))))
mixi-me)
(defconst mixi-favorite-list-regexp
"<td bgcolor=\"#FDF9F2\"><font color=\"#996600\">̾Á°</font></td>
-<td colspan=\"2\" bgcolor=\"#FFFFFF\"><a href=\"show_friend.pl\\?id=\\([0-9]+\\)\">\\(.*\\)</a></td>")
+<td colspan=\"2\" bgcolor=\"#FFFFFF\"><a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*\\)</a></td>")
;;;###autoload
(defun mixi-get-favorites (&optional range)
(defconst mixi-diary-title-regexp
"<td \\(bgcolor\\|BGCOLOR\\)=\"?#FFF4E0\"? width=\"?430\"?> \\([^<]+\\)</td>")
(defconst mixi-diary-content-regexp
- "<td \\(class\\|CLASS\\)=\"?h12\"?>\\(.*\\)</td>")
+ "<td \\(class\\|CLASS\\)=\"?h12\"?>\\(\\(.\\|\n\\)*?\\)</td>")
(defun mixi-realize-diary (diary &optional page)
"Realize a DIARY."
(defconst mixi-community-name-regexp
"<td WIDTH=345>\\(.*\\)</td></tr>")
(defconst mixi-community-birthday-regexp
- "<td BGCOLOR=#F2DDB7 WIDTH=80><font COLOR=#996600>³«ÀßÆü</font></td>\r
+ "<td BGCOLOR=#F2DDB7 WIDTH=80><font COLOR=#996600>³«ÀßÆü</font></td>
<td WIDTH=345>\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü")
;; FIXME: Care when the owner has seceded.
(defconst mixi-community-owner-regexp
- "<td BGCOLOR=#F2DDB7 WIDTH=80><font COLOR=#996600>´ÉÍý¿Í</font></td>\r
-<td WIDTH=345>\r
-<table style=\"width: 100%;\"><tr><td>\r
+ "<td BGCOLOR=#F2DDB7 WIDTH=80><font COLOR=#996600>´ÉÍý¿Í</font></td>
+<td WIDTH=345>
+<table style=\"width: 100%;\"><tr><td>
<a href=\"\\(home\\.pl\\|show_friend\\.pl\\?id=\\([0-9]+\\)\\)\">\\(.*\\)</a>")
(defconst mixi-community-category-regexp
- "<td BGCOLOR=#F2DDB7 WIDTH=80><font COLOR=#996600>¥«¥Æ¥´¥ê</font></td>\r
+ "<td BGCOLOR=#F2DDB7 WIDTH=80><font COLOR=#996600>¥«¥Æ¥´¥ê</font></td>
<td WIDTH=345>\\([^<]+\\)</td>")
(defconst mixi-community-members-regexp
- "<td BGCOLOR=#F2DDB7 WIDTH=80><font COLOR=#996600>¥á¥ó¥Ð¡¼¿ô</font></td>\r
+ "<td BGCOLOR=#F2DDB7 WIDTH=80><font COLOR=#996600>¥á¥ó¥Ð¡¼¿ô</font></td>
<td WIDTH=345>\\([0-9]+\\)¿Í</td></tr>")
(defconst mixi-community-open-level-regexp
- "<td BGCOLOR=#F2DDB7 WIDTH=80><font COLOR=#996600>»²²Ã¾ò·ï¤È<br>¸ø³«¥ì¥Ù¥ë</font></td>\r
+ "<td BGCOLOR=#F2DDB7 WIDTH=80><font COLOR=#996600>»²²Ã¾ò·ï¤È<br>¸ø³«¥ì¥Ù¥ë</font></td>
<td WIDTH=345>\\(.+\\)</td></tr>")
(defconst mixi-community-authority-regexp
- "<td BGCOLOR=#F2DDB7 WIDTH=80><font COLOR=#996600>¥È¥Ô¥Ã¥¯ºîÀ®¤Î¸¢¸Â</font></td>\r
+ "<td BGCOLOR=#F2DDB7 WIDTH=80><font COLOR=#996600>¥È¥Ô¥Ã¥¯ºîÀ®¤Î¸¢¸Â</font></td>
<td WIDTH=345>\\(.+\\)</td></tr>")
(defconst mixi-community-description-regexp
"<td CLASS=h120 WIDTH=345>\\(.+\\)</td>")
(defconst mixi-news-finished-regexp
"<td ALIGN=center background=http://img\\.mixi\\.jp/img/bg_line\\.gif> ¿½¤·Ìõ¤´¤¶¤¤¤Þ¤»¤ó¤¬¡¢¤³¤Î¥Ë¥å¡¼¥¹¤Ï·ÇºÜ½ªÎ»¤·¤Þ¤·¤¿¡£</td>")
(defconst mixi-news-title-regexp
- "<td HEIGHT=\"46\" STYLE=\"font-weight: bold;font-size: 14px;\" CLASS=\"h130\">\\(.+\\)\\(\r
+ "<td HEIGHT=\"46\" STYLE=\"font-weight: bold;font-size: 14px;\" CLASS=\"h130\">\\(.+\\)\\(
\\)?</td>")
(defconst mixi-news-media-time-regexp
"<td COLSPAN=\"2\" ALIGN=\"right\">(\\(.+\\) - \\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\))</td></tr>")