;; mixi.el --- API libraries for accessing to mixi -*- coding: euc-jp -*-
-;; Copyright (C) 2005, 2006, 2007 OHASHI Akira
+;; Copyright (C) 2005, 2006, 2007, 2008 OHASHI Akira
;; Author: OHASHI Akira <bg66@koka-in.org>
;; Keywords: hypermedia
;; * mixi-get-friends
;; * mixi-get-favorites
;; * mixi-get-logs
+;; * mixi-get-recommended-friends (indies)
;; * mixi-get-diaries
;; * mixi-get-new-diaries
;; * mixi-search-diaries
;; * mixi-get-communities
;; * mixi-search-communities
+;; * mixi-get-recommended-communities (indies)
;; * mixi-get-bbses
;; * mixi-get-new-bbses
;; * mixi-search-bbses
;; * mixi-get-messages
;; * mixi-get-introductions (broken)
;; * mixi-get-news
+;; * mixi-get-releases
;;
;; APIs for posting:
;;
(autoload 'w3m-retrieve "w3m")
(autoload 'url-retrieve-synchronously "url"))
-(defconst mixi-revision "$Revision: 1.176 $")
+(defconst mixi-revision "$Revision: 1.185 $")
(defgroup mixi nil
"API library for accessing to mixi."
(let ((page 1)
ids)
(catch 'end
- (while (or (null range) (< (length ids) range))
+ (while (and (or (null range) (< (length ids) range))
+ (or (= page 1) (and (stringp url) (string-match "%d" url))))
(with-mixi-retrieve (when url (format url page))
(let ((func (if reverse (progn
(goto-char (point-max))
(string-to-number (nth 0 item)))))
items)))
+;; Recommended friend.
+(defmacro mixi-recommended-friend-list-page ()
+ `(concat "http://indies.mixi.jp/recommend.pl"))
+
+(defconst mixi-recommended-friend-list-regexp
+ "<div class=\"iconListImage\"><a href=\"http://mixi\\.jp/show_friend\\.pl\\?id=\\([0-9]+\\)\" [^>]+>.+</a></div><span>\\(.+?\\)¤µ¤ó([0-9]+)</span>")
+
+;;;###autoload
+(defun mixi-get-recommended-friends (&optional range)
+ "Get recommended friends."
+ (let ((items (mixi-get-matched-items (mixi-recommended-friend-list-page)
+ mixi-recommended-friend-list-regexp
+ range)))
+ (mapcar (lambda (item)
+ (mixi-make-friend (nth 0 item) (nth 1 item)))
+ items)))
+
;; Diary object.
(defvar mixi-diary-cache (make-hash-table :test 'equal))
(defun mixi-make-diary (owner id &optional comment-count time title content)
(mixi-make-community (nth 0 item) (nth 1 item)))
items)))
+;; Recommended community.
+(defalias 'mixi-recommended-community-list-page
+ 'mixi-recommended-friend-list-page)
+
+(defconst mixi-recommended-community-list-regexp
+ "<div class=\"iconListImage\"><a href=\"http://mixi\\.jp/view_community\\.pl\\?id=\\([0-9]+\\)\" [^>]+>.+</a></div><span>\\(.+\\)([0-9]+)</span>")
+
+;;;###autoload
+(defun mixi-get-recommended-communities (&optional range)
+ "Get recommended communities."
+ (let ((items (mixi-get-matched-items (mixi-recommended-community-list-page)
+ mixi-recommended-community-list-regexp
+ range)))
+ (mapcar (lambda (item)
+ (mixi-make-community (nth 0 item) (nth 1 item)))
+ items)))
+
;; Topic object.
(defvar mixi-topic-cache (make-hash-table :test 'equal))
(defun mixi-make-topic (community id &optional comment-count time title owner
;;;###autoload
(defun mixi-get-bbses (community &optional range)
- "Get bbese of COMMUNITY."
+ "Get bbses of COMMUNITY."
(unless (mixi-community-p community)
(signal 'wrong-type-argument (list 'mixi-community-p community)))
(let ((items (mixi-get-matched-items (mixi-bbs-list-page community)
<span class=\"commentTitleDate\">\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\)</span>
</dt>
-
-
+
<dd>
\\(\\(.\\|\r?\n\\)*?\\)
;; FIXME: Split regexp to time, owner(id and nick) and contents.
(defconst mixi-event-comment-list-regexp
- "<dt class=\"commentDate clearfix\"><span class=\"senderId\">\\(<input id=\"commentCheck01\" name=\"comment_id\" type=\"checkbox\" value=\"[0-9]+\" /><label for=\"commentCheck01\">\\|\\)\\([0-9]+\\)\\(<span class=\"deleteTextArea\"><a href=\"delete_bbs_comment\\.pl\\?id=[0-9]+&comm_id=[0-9]+&comment_id=[0-9]+\">¼«Ê¬¤Î¥³¥á¥ó¥È¤òºï½ü¤¹¤ë</a></span>\\|</label>\\|\\)</span>
+ "<dt class=\"commentDate clearfix\"><span class=\"senderId\">\\(<input id=\"commentCheck01\" name=\"comment_id\" type=\"checkbox\" value=\"[0-9]+\" /><label for=\"commentCheck01\">\\|\\)\\([0-9]+\\)\\(<span class=\"deleteTextArea\"><a href=\"delete_bbs_comment\\.pl\\?id=[0-9]+&comm_id=[0-9]+&comment_id=[0-9]+&type=event\">¼«Ê¬¤Î¥³¥á¥ó¥È¤òºï½ü¤¹¤ë</a></span>\\|</label>\\|\\)</span>
<span class=\"date\">\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\)</span></dt>
<dd>
<dl class=\"commentContent01\">
"&media_id=" (mixi-news-media-id ,news)))
(defconst mixi-news-finished-regexp
- "¿½¤·Ìõ¤´¤¶¤¤¤Þ¤»¤ó¤¬¡¢¤³¤Î¥Ë¥å¡¼¥¹¤Ï·ÇºÜ¤¬½ªÎ»¤·¤¿¤«¡¢URL¤¬´Ö°ã¤Ã¤Æ¤¤¤¤¤ë¤¿¤á¤´Í÷¤¤¤¿¤À¤±¤Þ¤»¤ó¡£</td>")
+ "<p class=\"supplement01\">¢¨¿½¤·Ìõ¤¢¤ê¤Þ¤»¤ó¤¬¡¢¤³¤Î¥Ë¥å¡¼¥¹¤Ï·ÇºÜ´ü´Ö¤¬½ªÎ»¤·¤¿¤«¡¢URL¤¬´Ö°ã¤Ã¤Æ¤¤¤ë¤¿¤á¤´Í÷¤¤¤¿¤À¤±¤Þ¤»¤ó¡£¾Ü¤·¤¯¤Ï<a href=\"http://mixi.jp/help.pl#16h\">¤³¤Á¤é</a>¤ò¤´Í÷¤¯¤À¤µ¤¤¡£</p>")
(defconst mixi-news-title-regexp
- "<td HEIGHT=\"46\" STYLE=\"font-weight: bold;font-size: 14px;\" CLASS=\"h130\">\\(.+\\)\\(
-\\)?</td>")
+ "<div class=\"articleH[ae][ae]ding\">
+<h2>\\(.+\\)</h2>")
(defconst mixi-news-media-time-regexp
- "<td COLSPAN=\"2\" ALIGN=\"right\">(\\(.+\\) - \\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\))</td></tr>")
+ "<p class=\"date\">¡Ê\\(.+\\) - \\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\)¡Ë</p>")
(defconst mixi-news-content-regexp
- "<td CLASS=\"h150\">
-
+ "<div class=\"article\">
\\(.+\\)
-<br>
-\\(.*
-\\)?
-
-\\(</td>\\|<br>\\)")
++
+\\(</div>
+</div>\\|<div class=\"additional\">\\)")
(defun mixi-realize-news (news)
"Realize a NEWS."
(aset (cdr news) 6 content))
(defconst mixi-news-category-list '(domestic politics economy area abroad
- sports entertainment IT))
+ sports entertainment IT game-anime
+ column))
(defmacro mixi-news-category-p (category)
`(memq ,category mixi-news-category-list))
"&type=bn"))
(defconst mixi-news-list-regexp
- "<tr bgcolor=\"\\(#FCF5EB\\|#FFFFFF\\)\">
-<td WIDTH=\"1%\" valign=top CLASS=\"h120\">¡¦</td>
-<td WIDTH=\"97%\" CLASS=\"h120\"><A HREF=\"view_news\\.pl\\?id=\\([0-9]+\\)&media_id=\\([0-9]+\\)\"class=\"new_link\">\\(.+\\)</A>
-\\(<IMG SRC=\"http://img\\.mixi\\.jp/img/news_camera3\\.gif\" WIDTH=\"11\" HEIGHT=\"12\">\\|\\)
-
-</td>
-<td WIDTH=\"1%\" nowrap CLASS=\"f08\"><A HREF=\"list_news_media\\.pl\\?id=[0-9]+\">\\(.+\\)</A></td>
-<td WIDTH=\"1%\" nowrap CLASS=\"f08\">\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\)</td></tr>")
+ "<td class=\"newsTitle\"><p>¡¦ <a href=\"view_news\\.pl\\?id=\\([0-9]+\\)&media_id=\\([0-9]+\\)\">\\(.+\\)</a><img src=\"http://img\\.mixi\\.jp/img/news_camera3\\.gif\" width=\"11\" height=\"12\" alt=\"\" /></p></td>
+<td class=\"media\"><a href=\"list_news_media\\.pl\\?id=[0-9]+\">\\(.+\\)</a></td>
+<td class=\"date\">\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\)</td>")
;;;###autoload
(defun mixi-get-news (category sort &optional range)
(year (nth 5 (decode-time (current-time))))
(month (nth 4 (decode-time (current-time)))))
(mapcar (lambda (item)
- (let ((month-of-item (string-to-number (nth 6 item))))
+ (let ((month-of-item (string-to-number (nth 4 item))))
(when (> month-of-item month)
(decf year))
(setq month month-of-item)
- (mixi-make-news (nth 2 item) (nth 1 item) (nth 5 item)
+ (mixi-make-news (nth 1 item) (nth 0 item) (nth 3 item)
(encode-time
- 0 (string-to-number (nth 9 item))
- (string-to-number (nth 8 item))
- (string-to-number (nth 7 item))
+ 0 (string-to-number (nth 7 item))
+ (string-to-number (nth 6 item))
+ (string-to-number (nth 5 item))
month year)
- (nth 3 item))))
+ (nth 2 item))))
+ items)))
+
+;; Release object.
+(defun mixi-make-release (title time content)
+ "Return a release object."
+ (cons 'mixi-release (vector title time content)))
+
+(defmacro mixi-release-p (release)
+ `(eq (mixi-object-class ,release) 'mixi-release))
+
+(defun mixi-release-title (release)
+ "Return the title of RELEASE."
+ (unless (mixi-release-p release)
+ (signal 'wrong-type-argument (list 'mixi-release-p release)))
+ (aref (cdr release) 0))
+
+(defun mixi-release-time (release)
+ "Return the time of RELEASE."
+ (unless (mixi-release-p release)
+ (signal 'wrong-type-argument (list 'mixi-release-p release)))
+ (aref (cdr release) 1))
+
+(defun mixi-release-content (release)
+ "Return the content of RELEASE."
+ (unless (mixi-release-p release)
+ (signal 'wrong-type-argument (list 'mixi-release-p release)))
+ (aref (cdr release) 2))
+
+(defmacro mixi-release-list-page ()
+ `(concat "/release_info.pl?page=%d"))
+
+(defconst mixi-release-list-regexp
+ "<td> <span STYLE=\"font-size:8pt;color:#DFB479\">¢£</span> <b><font COLOR=#605048>\\(.+\\)</font></b></td>
+<td ALIGN=right><font COLOR=#605048>\\([1-9][0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)</font></td>
+</tr>
+</table>
+</td>
+</tr>
+</table>
+
+<br>
+
+<table BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=450>
+<tr>
+<td CLASS=h130>
+\\(.+\\)
+</td>
+</tr>
+</table>")
+
+;;;###autoload
+(defun mixi-get-releases (&optional range)
+ "Get releases."
+ (let ((items (mixi-get-matched-items (mixi-release-list-page)
+ mixi-release-list-regexp
+ range)))
+ (mapcar (lambda (item)
+ (mixi-make-release (nth 0 item)
+ (encode-time 0 0 0
+ (string-to-number (nth 3 item))
+ (string-to-number (nth 2 item))
+ (string-to-number (nth 1 item)))
+ (nth 4 item)))
items)))
(provide 'mixi)