2006-11-27 OHASHI Akira <bg66@koka-in.org>
+ * mixi.el (mixi-event-cache): New variable.
+ (mixi-make-event): New function.
+ (mixi-event-url-regexp): New constant.
+ (mixi-make-event-from-url): New function.
+ (mixi-event-p): New macro.
+ (mixi-event-page): Ditto.
+ (mixi-event-time-regexp): New regexp.
+ (mixi-event-title-regexp): Ditto.
+ (mixi-event-owner-regexp): Ditto.
+ (mixi-event-date-regexp): Ditto.
+ (mixi-event-place-regexp): Ditto.
+ (mixi-event-detail-regexp): Ditto.
+ (mixi-event-limit-regexp): Ditto.
+ (mixi-event-members-regexp): Ditto.
+ (mixi-event-realize): New function.
+ (mixi-event-community): New accessor method.
+ (mixi-event-id): Ditto.
+ (mixi-event-time): Ditto.
+ (mixi-event-title): Ditto.
+ (mixi-event-owner): Ditto.
+ (mixi-event-date): Ditto.
+ (mixi-event-place): Ditto.
+ (mixi-event-detail): Ditto.
+ (mixi-event-limit): Ditto.
+ (mixi-event-members): Ditto.
+ (mixi-event-set-time): Ditto.
+ (mixi-event-set-title): Ditto.
+ (mixi-event-set-owner): Ditto.
+ (mixi-event-set-date): Ditto.
+ (mixi-event-set-place): Ditto.
+ (mixi-event-set-detail): Ditto.
+ (mixi-event-set-limit): Ditto.
+ (mixi-event-set-members): Ditto.
+ (mixi-bbs-list-page): Rename from `mixi-topic-list-page'.
+ (mixi-bbs-list-regexp): Rename from `mixi-topic-list-regexp'.
+ (mixi-get-bbses): Rename from `mixi-get-topics'.
+ (mixi-new-bbs-list-page): Rename from `mixi-new-topic-list-page'.
+ (mixi-new-bbs-list-regexp): Rename from `mixi-new-topic-list-regexp'.
+ (mixi-get-new-bbses): Rename from `mixi-get-new-topics'.
+ (mixi-bbs-list-regexp): Follow the change above.
+ (mixi-get-bbses): Ditto.
+ (mixi-new-bbs-list-regexp): Ditto.
+ (mixi-get-new-bbses): Ditto.
+ (mixi-event-comment-list-page): New function.
+ (mixi-event-comment-list-regexp): New constant.
+
+ * sb-mixi.el (shimbun-mixi-group-alist): Follow the change above.
+ (shimbun-mixi-make-subject): Ditto.
+ (shimbun-mixi-make-xref): Ditto.
+ (shimbun-mixi-get-headers): Ditto.
+ (shimbun-get-headers): Ditto.
+ (shimbun-mixi-make-body): New function.
+ (shimbun-article): Follow the change above.
+
+2006-11-27 OHASHI Akira <bg66@koka-in.org>
+
* sb-mixi.el (shimbun-mixi-get-headers): Don't quit even if there are
comments which have already gotten.
;; * mixi-get-diaries
;; * mixi-get-new-diaries
;; * mixi-get-communities
-;; * mixi-get-topics
-;; * mixi-get-new-topics
+;; * mixi-get-bbses
+;; * mixi-get-new-bbses
;; * mixi-get-comments
;; * mixi-get-new-comments
;; * mixi-get-messages
(signal 'wrong-type-argument (list 'mixi-topic-p topic)))
(aset (cdr topic) 6 content))
-(defmacro mixi-topic-list-page (community)
+;; Event object.
+(defvar mixi-event-cache (make-hash-table :test 'equal))
+(defun mixi-make-event (community id)
+ "Return a event object."
+ (mixi-make-cache (list (mixi-community-id community) id)
+ (cons 'mixi-event (vector nil community id nil nil nil nil
+ nil nil nil nil))
+ mixi-event-cache))
+
+(defconst mixi-event-url-regexp
+ "/view_event\\.pl\\?id=\\([0-9]+\\)\\(&comment_count=[0-9]+\\)?&comm_id=\\([0-9]+\\)")
+
+(defun mixi-make-event-from-url (url)
+ "Return a event object from URL."
+ (when (string-match mixi-event-url-regexp url)
+ (let ((id (match-string 1 url))
+ (community-id (match-string 3 url)))
+ (mixi-make-event (mixi-make-community community-id) id))))
+
+(defmacro mixi-event-p (event)
+ `(eq (mixi-object-class ,event) 'mixi-event))
+
+(defmacro mixi-event-page (event)
+ `(concat "/view_event.pl?id=" (mixi-event-id ,event)
+ "&comm_id=" (mixi-community-id (mixi-event-community ,event))))
+
+(defconst mixi-event-time-regexp
+ "<td ROWSPAN=11 BGCOLOR=#FFD8B0 ALIGN=center VALIGN=top WIDTH=110>
+\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü<br>
+\\([0-9]+\\):\\([0-9]+\\)</td>")
+(defconst mixi-event-title-regexp
+ "<td bgcolor=#FFF4E0 width=410> \\([^<]+\\)</td>")
+(defconst mixi-event-owner-regexp
+ "<td BGCOLOR=#FDF9F2> <a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*\\)</a>")
+(defconst mixi-event-date-regexp
+ "<td BGCOLOR=#FFFFFF ALIGN=center NOWRAP>³«ºÅÆü»þ</td>
+<td BGCOLOR=#FFFFFF>
+ \\(.+\\)
+</td>")
+(defconst mixi-event-place-regexp
+ "<td BGCOLOR=#FFFFFF ALIGN=center NOWRAP>³«ºÅ¾ì½ê</td>
+<td BGCOLOR=#FFFFFF>
+ \\(.+\\)
+</td>")
+(defconst mixi-event-detail-regexp
+ "<td BGCOLOR=#FFFFFF ALIGN=center NOWRAP>¾ÜºÙ</td>
+<td BGCOLOR=#FFFFFF><table BORDER=0 CELLSPACING=0 CELLPADDING=5><tr><td CLASS=h120>\\(.+\\)</td></tr></table></td>")
+(defconst mixi-event-limit-regexp
+ "<td BGCOLOR=#FFFFFF ALIGN=center NOWRAP>Ê罸´ü¸Â</td>
+<td BGCOLOR=#FFFFFF> \\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü</td>")
+(defconst mixi-event-members-regexp
+ "<td BGCOLOR=#FFFFFF ALIGN=center NOWRAP>»²²Ã¼Ô</td>
+<td BGCOLOR=#FFFFFF>
+<table BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%>
+<tr>
+<td> \\(.+\\)</td>")
+
+(defun mixi-event-realize (event)
+ "Realize a EVENT."
+ ;; FIXME: Check a expiration of cache?
+ (unless (mixi-object-realize-p event)
+ (with-mixi-retrieve (mixi-event-page event)
+ (if (string-match mixi-event-time-regexp buffer)
+ (mixi-event-set-time
+ event (encode-time 0 (string-to-number (match-string 5 buffer))
+ (string-to-number (match-string 4 buffer))
+ (string-to-number (match-string 3 buffer))
+ (string-to-number (match-string 2 buffer))
+ (string-to-number (match-string 1 buffer))))
+ (signal 'error (list 'cannot-find-time event)))
+ (if (string-match mixi-event-title-regexp buffer)
+ (mixi-event-set-title event (match-string 1 buffer))
+ (signal 'error (list 'cannot-find-title event)))
+ (if (string-match mixi-event-owner-regexp buffer)
+ (mixi-event-set-owner event
+ (mixi-make-friend (match-string 1 buffer)
+ (match-string 2 buffer)))
+ (signal 'error (list 'cannot-find-owner event)))
+ (if (string-match mixi-event-date-regexp buffer)
+ (mixi-event-set-date event (match-string 1 buffer))
+ (signal 'error (list 'cannot-find-date event)))
+ (if (string-match mixi-event-place-regexp buffer)
+ (mixi-event-set-place event (match-string 1 buffer))
+ (signal 'error (list 'cannot-find-place event)))
+ (if (string-match mixi-event-detail-regexp buffer)
+ (mixi-event-set-detail event (match-string 1 buffer))
+ (signal 'error (list 'cannot-find-detail event)))
+ (when (string-match mixi-event-limit-regexp buffer)
+ (mixi-event-set-limit
+ event (encode-time 0 0 0 (string-to-number (match-string 3 buffer))
+ (string-to-number (match-string 2 buffer))
+ (string-to-number (match-string 1 buffer)))))
+ (if (string-match mixi-event-members-regexp buffer)
+ (mixi-event-set-members event (match-string 1 buffer))
+ (signal 'error (list 'cannot-find-members event))))
+ (mixi-object-touch event)))
+
+(defun mixi-event-community (event)
+ "Return the community of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (aref (cdr event) 1))
+
+(defun mixi-event-id (event)
+ "Return the id of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (aref (cdr event) 2))
+
+(defun mixi-event-time (event)
+ "Return the time of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (mixi-event-realize event)
+ (aref (cdr event) 3))
+
+(defun mixi-event-title (event)
+ "Return the title of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (mixi-event-realize event)
+ (aref (cdr event) 4))
+
+(defun mixi-event-owner (event)
+ "Return the owner of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (mixi-event-realize event)
+ (aref (cdr event) 5))
+
+(defun mixi-event-date (event)
+ "Return the date of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (mixi-event-realize event)
+ (aref (cdr event) 6))
+
+(defun mixi-event-place (event)
+ "Return the place of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (mixi-event-realize event)
+ (aref (cdr event) 7))
+
+(defun mixi-event-detail (event)
+ "Return the detail of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (mixi-event-realize event)
+ (aref (cdr event) 8))
+
+(defun mixi-event-limit (event)
+ "Return the limit of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (mixi-event-realize event)
+ (aref (cdr event) 9))
+
+(defun mixi-event-members (event)
+ "Return the members of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (mixi-event-realize event)
+ (aref (cdr event) 10))
+
+(defun mixi-event-set-time (event time)
+ "Set the time of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (aset (cdr event) 3 time))
+
+(defun mixi-event-set-title (event title)
+ "Set the title of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (aset (cdr event) 4 title))
+
+(defun mixi-event-set-owner (event owner)
+ "Set the owner of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (unless (mixi-friend-p owner)
+ (signal 'wrong-type-argument (list 'mixi-friend-p owner)))
+ (aset (cdr event) 5 owner))
+
+(defun mixi-event-set-date (event date)
+ "Set the date of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (aset (cdr event) 6 date))
+
+(defun mixi-event-set-place (event place)
+ "Set the place of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (aset (cdr event) 7 place))
+
+(defun mixi-event-set-detail (event detail)
+ "Set the detail of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (aset (cdr event) 8 detail))
+
+(defun mixi-event-set-limit (event limit)
+ "Set the limit of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (aset (cdr event) 9 limit))
+
+(defun mixi-event-set-members (event members)
+ "Set the members of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (aset (cdr event) 10 members))
+
+;; Bbs.
+(defmacro mixi-bbs-list-page (community)
`(concat "/list_bbs.pl?page=%d"
"&id=" (mixi-community-id ,community)))
-(defconst mixi-topic-list-regexp
- "<a href=view_bbs\\.pl\\?id=\\([0-9]+\\)")
+(defconst mixi-bbs-list-regexp
+ "<a href=view_\\(bbs\\|event\\)\\.pl\\?id=\\([0-9]+\\)")
-(defun mixi-get-topics (community &optional max-numbers)
- "Get topics of COMMUNITY."
+(defun mixi-get-bbses (community &optional max-numbers)
+ "Get bbese of COMMUNITY."
(unless (mixi-community-p community)
(signal 'wrong-type-argument (list 'mixi-community-p community)))
- (let ((items (mixi-get-matched-items (mixi-topic-list-page community)
+ (let ((items (mixi-get-matched-items (mixi-bbs-list-page community)
max-numbers
- mixi-topic-list-regexp)))
+ mixi-bbs-list-regexp)))
(mapcar (lambda (item)
- (mixi-make-topic community (nth 0 item)))
+ (let ((name (nth 0 item)))
+ (when (string= name "bbs")
+ (setq name "topic"))
+ (let ((func (intern (concat "mixi-make-" name))))
+ (funcall func community (nth 1 item)))))
items)))
-(defmacro mixi-new-topic-list-page ()
+(defmacro mixi-new-bbs-list-page ()
`(concat "/new_bbs.pl?page=%d"))
-(defconst mixi-new-topic-list-regexp
- "<a href=\"view_bbs\\.pl\\?id=\\([0-9]+\\)&comment_count=[0-9]+&comm_id=\\([0-9]+\\)\" class=\"new_link\">")
+(defconst mixi-new-bbs-list-regexp
+ "<a href=\"view_\\(bbs\\|event\\)\\.pl\\?id=\\([0-9]+\\)&comment_count=[0-9]+&comm_id=\\([0-9]+\\)\" class=\"new_link\">")
-(defun mixi-get-new-topics (&optional max-numbers)
+(defun mixi-get-new-bbses (&optional max-numbers)
"Get new topics."
- (let ((items (mixi-get-matched-items (mixi-new-topic-list-page)
+ (let ((items (mixi-get-matched-items (mixi-new-bbs-list-page)
max-numbers
- mixi-new-topic-list-regexp)))
+ mixi-new-bbs-list-regexp)))
(mapcar (lambda (item)
- (mixi-make-topic (mixi-make-community (nth 1 item))
- (nth 0 item)))
+ (let ((name (nth 0 item)))
+ (when (string= name "bbs")
+ (setq name "topic"))
+ (let ((func (intern (concat "mixi-make-" name))))
+ (funcall func (mixi-make-community (nth 2 item))
+ (nth 1 item)))))
items)))
;; Comment object.
</td>
</tr>")
+(defun mixi-event-comment-list-page (event)
+ (concat "/view_event.pl?page=all"
+ "&id=" (mixi-event-id event)
+ "&comm_id=" (mixi-community-id (mixi-event-community event))))
+
+;; FIXME: Split regexp to time, owner(id and nick) and contents.
+(defconst mixi-event-comment-list-regexp
+ "<tr>
+<td ROWSPAN=2 ALIGN=center BGCOLOR=#F2DDB7 WIDTH=110>
+\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü<br>
+\\([0-9]+\\):\\([0-9]+\\)<br>
+\\(</td>\\)
+\\(<td BGCOLOR=#FDF9F2>\\)
+<font COLOR=#F8A448><b>[^<]+</b> :</font>
+<a HREF=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*\\)</a>
+
+</td>
+</tr>
+\\(<tr>\\)
+<td ALIGN=center BGCOLOR=#FFFFFF>
+<table BORDER=0 CELLSPACING=0 CELLPADDING=5 WIDTH=500>
+<tr><td CLASS=h120>\\(.+\\)</td></tr>
+</table>
+</td>
+</tr>")
+
(defun mixi-get-comments (parent &optional max-numbers)
"Get comments of PARENT."
(unless (mixi-object-p parent)
(defcustom shimbun-mixi-group-alist '(("new-diaries" . mixi-get-new-diaries)
("new-comments" . mixi-get-new-comments)
- ("new-topics" . mixi-get-new-topics)
+ ("new-bbses" . mixi-get-new-bbses)
("messages" . mixi-get-messages)
("my-diaries" . "/home.pl"))
"*An alist of mixi shimbun group definition.
Each element looks like (NAME . URL) or (NAME . FUNCTION).
NAME is a shimbun group name.
URL is the URL for mixi access point of the group. When URL is friend's, get
-his/her diaries as article. When community's, get its topics. When diary's
-or topic's, get its comments.
+his/her diaries as article. When community's, get its BBSes. When diary's
+or BBS's, get its comments.
FUNCTION is the function for getting articles."
:group 'shimbun
:type '(repeat (cons :fromat "%v"
(radio (string :tag "URL")
(const :tag "New diaries" mixi-get-new-diaries)
(const :tag "New comments" mixi-get-new-comments)
- (const :tag "New topics" mixi-get-new-topics)
+ (const :tag "New BBSes" mixi-get-new-bbses)
(const :tag "Messages" mixi-get-messages)
(function :tag "Other function")))))
:type 'integer)
(defcustom shimbun-mixi-get-comment-p t
- "*If non-nil, get diaries or topics together with its comments."
+ "*If non-nil, get diaries or BBSes together with its comments."
:group 'shimbun
:type 'boolean)
(defun shimbun-mixi-make-subject (object)
(let ((class (mixi-object-class object)))
- (if (eq class 'mixi-comment)
- (concat "Re: " (mixi-object-title (mixi-comment-parent object)))
- (mixi-object-title object))))
+ (cond ((eq class 'mixi-comment)
+ (concat "Re: " (shimbun-mixi-make-subject
+ (mixi-comment-parent object))))
+ ((eq class 'mixi-event)
+ (concat "[¥¤¥Ù¥ó¥È]" (mixi-object-title object)))
+ (t (mixi-object-title object)))))
(defun shimbun-mixi-make-from (object)
(let ((owner (mixi-object-owner object)))
(mixi-expand-url (mixi-diary-page object)))
((eq class 'mixi-topic)
(mixi-expand-url (mixi-topic-page object)))
+ ((eq class 'mixi-event)
+ (mixi-expand-url (mixi-event-page object)))
((eq class 'mixi-comment)
(concat (shimbun-mixi-make-xref (mixi-comment-parent object))
"#comment"))
((eq class 'mixi-message)
(mixi-expand-url (mixi-message-page object))))))
+(defun shimbun-mixi-make-body (object)
+ (let ((class (mixi-object-class object)))
+ (if (eq class 'mixi-event)
+ (let ((limit (mixi-event-limit object)))
+ (setq limit (if limit
+ (format-time-string "%Yǯ%m·î%dÆü" limit)
+ "»ØÄê¤Ê¤·"))
+ (concat "<dl><dt>³«ºÅÆü»þ¡§</dt>"
+ "<dd>" (mixi-event-date object) "</dd>"
+ "<dt>³«ºÅ¾ì½ê¡§</dt>"
+ "<dd>" (mixi-event-place object) "</dd>"
+ "<dt>¾ÜºÙ¡§</dt>"
+ "<dd>" (mixi-event-detail object) "</dd>"
+ "<dt>Ê罸´ü¸Â¡§</dt>"
+ "<dd>" limit "</dd>"
+ "<dt>»²²Ã¼Ô¡§</dt>"
+ "<dd>" (mixi-event-members object) "</dd></dl>"))
+ (mixi-object-content object))))
+
(defun shimbun-mixi-get-headers (shimbun objects &optional range)
(when objects
(let (headers)
headers)
(when (and shimbun-mixi-get-comment-p
(or (eq class 'mixi-diary)
- (eq class 'mixi-topic)))
+ (eq class 'mixi-topic)
+ (eq class 'mixi-event)))
(let ((comments (mixi-get-comments object range)))
(mapc (lambda (header)
(push header headers))
(cond ((eq class 'mixi-friend)
(setq objects (mixi-get-diaries object range)))
((eq class 'mixi-community)
- (setq objects (mixi-get-topics object range)))
- ((or (eq class 'mixi-diary) (eq class 'mixi-topic))
+ (setq objects (mixi-get-bbses object range)))
+ ((or (eq class 'mixi-diary)
+ (eq class 'mixi-topic)
+ (eq class 'mixi-event))
(setq objects (mixi-get-comments object range)))
(t (error (concat (symbol-name class)
" is not supported yet.")))))
(article (if (string-match "#comment$" url)
(shimbun-comment-article url header)
;; FIXME: Concat community information?
- (mixi-object-content
+ (shimbun-mixi-make-body
(mixi-make-object-from-url url)))))
(when (stringp article)
(insert article)))