* mixi.el (mixi-make-release): New function.
authorbg66 <bg66>
Tue, 12 Feb 2008 11:05:21 +0000 (11:05 +0000)
committerbg66 <bg66>
Tue, 12 Feb 2008 11:05:21 +0000 (11:05 +0000)
(mixi-release-p): New macro.
(mixi-release-title): New function.
(mixi-release-time): Ditto.
(mixi-release-content): Ditto.
(mixi-release-list-page): New macro.
(mixi-release-list-regexp): New constant.
(mixi-get-releases): New function.
* mixi-utils.el (mixi-make-author): Support release object.
(mixi-make-id-1): Ditto.
(mixi-make-url): Ditto.
(mixi-make-reply-to): Ditto.
* sb-mixi.el (shimbun-mixi): Add release-cache.
(shimbun-mixi-default-group-alist): Add releases group.
(initialize-instance): Initialize release cache.
(shimbun-close): Clear release cache.
(shimbun-mixi-release-article): New function.
(shimbun-article): Use it.

ChangeLog
mixi-ja.texi
mixi-utils.el
mixi.el
sb-mixi.el

index b4e6db5..da258a0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,26 @@
 2008-02-12  OHASHI Akira  <bg66@koka-in.org>
 
+       * mixi.el (mixi-make-release): New function.
+       (mixi-release-p): New macro.
+       (mixi-release-title): New function.
+       (mixi-release-time): Ditto.
+       (mixi-release-content): Ditto.
+       (mixi-release-list-page): New macro.
+       (mixi-release-list-regexp): New constant.
+       (mixi-get-releases): New function.
+       * mixi-utils.el (mixi-make-author): Support release object.
+       (mixi-make-id-1): Ditto.
+       (mixi-make-url): Ditto.
+       (mixi-make-reply-to): Ditto.
+       * sb-mixi.el (shimbun-mixi): Add release-cache.
+       (shimbun-mixi-default-group-alist): Add releases group.
+       (initialize-instance): Initialize release cache.
+       (shimbun-close): Clear release cache.
+       (shimbun-mixi-release-article): New function.
+       (shimbun-article): Use it.
+
+2008-02-12  OHASHI Akira  <bg66@koka-in.org>
+
        * mixi.el (mixi-news-finished-regexp): Follow the change of mixi.
        (mixi-news-title-regexp): Ditto.
        (mixi-news-media-time-regexp): Ditto.
index e97cf7a..475c0ff 100755 (executable)
@@ -14,7 +14,7 @@
 @end direntry
 
 @copying
-Copyright @copyright{} 2007 @w{OHASHI Akira}.
+Copyright @copyright{} 2007, 2008 @w{OHASHI Akira}.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -370,7 +370,7 @@ ID \e$B$rJV5Q$7$^$9!#\e(B
 @end defun
 
 @defun mixi-diary-time diary
-\e$B;~9o$rJV5Q$7$^$9!#\e(B
+\e$BF|;~$rJV5Q$7$^$9!#\e(B
 @end defun
 
 @defun mixi-diary-title diary
@@ -469,7 +469,7 @@ ID \e$B$rJV5Q$7$^$9!#\e(B
 @end defun
 
 @defun mixi-topic-time topic
-\e$B;~9o$rJV5Q$7$^$9!#\e(B
+\e$BF|;~$rJV5Q$7$^$9!#\e(B
 @end defun
 
 @defun mixi-topic-title topic
@@ -517,7 +517,7 @@ ID \e$B$rJV5Q$7$^$9!#\e(B
 @end defun
 
 @defun mixi-event-time event
-\e$B;~9o$rJV5Q$7$^$9!#\e(B
+\e$BF|;~$rJV5Q$7$^$9!#\e(B
 @end defun
 
 @defun mixi-event-title event
@@ -568,7 +568,7 @@ comment \e$B%*%V%8%'%/%H$N3F<o>pJs$r<hF@$9$k$?$a$N%"%/%;%5%a%=%C%I$N0lMw$r0J\e(B
 @end defun
 
 @defun mixi-comment-time comment
-\e$B;~9o$rJV5Q$7$^$9!#\e(B
+\e$BF|;~$rJV5Q$7$^$9!#\e(B
 @end defun
 
 @defun mixi-comment-content comment
@@ -619,7 +619,7 @@ ID \e$B$rJV5Q$7$^$9!#\e(B
 @end defun
 
 @defun mixi-message-time message
-\e$B;~9o$rJV5Q$7$^$9!#\e(B
+\e$BF|;~$rJV5Q$7$^$9!#\e(B
 @end defun
 
 @defun mixi-message-content message
@@ -690,6 +690,31 @@ ID \e$B$rJV5Q$7$^$9!#\e(B
 @ref{mixi-remove-markup} \e$B$r;HMQ$9$k$3$H$,$G$-$^$9!#\e(B
 @end defun
 
+@subsection release \e$B%*%V%8%'%/%H\e(B
+@cindex release \e$B%*%V%8%'%/%H\e(B
+
+\e$B?75!G=%j%j!<%9!&>c32$N$4Js9p$rI=$9%*%V%8%'%/%H$G$9!#\e(B
+\e$B$3$N%*%V%8%'%/%H$rD>@\@8@.$9$k$3$H$OL5$$$H;W$$$^$9!#\e(B
+
+@subsubsection \e$B%"%/%;%5%a%=%C%I\e(B
+
+release \e$B%*%V%8%'%/%H$N3F<o>pJs$r<hF@$9$k$?$a$N%"%/%;%5%a%=%C%I$N0lMw$r0J2<\e(B
+\e$B$K2r@b$7$^$9!#\e(B
+
+@defun mixi-release-title release
+\e$B%?%$%H%k$rJV5Q$7$^$9!#\e(B
+@end defun
+
+@defun mixi-release-time release
+\e$BF|;~$rJV5Q$7$^$9!#\e(B
+@end defun
+
+@defun mixi-release-content release
+\e$BK\J8$rJV5Q$7$^$9!#\e(B
+\e$BK\J8$K$O\e(B HTML \e$B%?%0$,4^$^$l$F$$$k2DG=@-$,$"$j$^$9!#$=$l$i$r<h$j=|$/$?$a$K\e(B
+@ref{mixi-remove-markup} \e$B$r;HMQ$9$k$3$H$,$G$-$^$9!#\e(B
+@end defun
+
 @node \e$B0lMw<hF@4X?t\e(B
 @section \e$B0lMw<hF@4X?t\e(B
 
@@ -1105,6 +1130,23 @@ IT\e$B!&%F%/%N%m%8!<\e(B
 @end cartouche
 @end defun
 
+@defun mixi-get-releases &optional range
+\e$B?75!G=%j%j!<%9!&>c32$N$4Js9p0lMw$r<hF@$7$^$9!#\e(B
+@var{range} \e$B$O?tCM$r;XDj$9$k$3$H$,$G$-$^$9!#\e(B
+@var{range} \e$B$r;XDj$7$?>l9g$O:GBg$G$3$N?t$N?75!G=%j%j!<%9!&>c32$N$4Js9p$N\e(B
+\e$B$_$r<hF@$7$^$9!#\e(B
+
+@cartouche
+@example
+(mixi-get-releases)
+    @result{} \e$B?75!G=%j%j!<%9!&>c32$N$4Js9p$9$Y$F\e(B
+
+(mixi-get-releases 5)
+    @result{} \e$B?75!G=%j%j!<%9!&>c32$N$4Js9p:GBg$G\e(B 5 \e$B7oJ,$N$_\e(B
+@end example
+@end cartouche
+@end defun
+
 @node \e$BEj9FMQ4X?t\e(B
 @section \e$BEj9FMQ4X?t\e(B
 
index d2646d0..aad03b8 100644 (file)
@@ -1,6 +1,6 @@
 ;; mixi-utils.el --- Utilities for mixi object -*- coding: euc-jp -*-
 
-;; Copyright (C) 2007 OHASHI Akira
+;; Copyright (C) 2007, 2008 OHASHI Akira
 
 ;; Author: OHASHI Akira <bg66@koka-in.org>
 ;; Keywords: hypermedia
@@ -87,6 +87,8 @@
                (mixi-bbs-p (mixi-comment-parent object)))
           (concat (mixi-comment-count object) " "
                   (mixi-friend-nick (mixi-comment-owner object))))
+         ((eq class 'mixi-release)
+          "mixi±¿±Ä»ö̳¶É")
          (t
           (let ((owner (if (eq class 'mixi-log)
                            (mixi-log-friend object)
                                     (mixi-comment-parent object))) "."))
           ((eq class 'mixi-log)
            (concat (mixi-friend-id (mixi-log-friend object)) "@"))
+          ((eq class 'mixi-release)
+           (concat (md5 (mixi-release-title object)) "@"))
           (t
            (concat (mixi-object-id object) "@"
                    (if (eq class 'mixi-news)
           (mixi-expand-url (mixi-message-page object)))
          ((eq class 'mixi-news)
           (mixi-news-page object))
+         ((eq class 'mixi-release)
+          (let ((url (mixi-release-list-page)))
+            (mixi-expand-url (substring url 0
+                                        (string-match "?" url)))))
          ((eq class 'mixi-log)
           (mixi-expand-url (mixi-friend-page (mixi-log-friend object))))
          ((eq class 'mixi-friend)
                          (mixi-friend-id (mixi-message-owner object))))
                 ((or (eq class 'mixi-friend) (eq class 'mixi-log))
                  (concat mixi-reply-to "message;"
-                         (mixi-friend-id object))))))))
+                         (mixi-friend-id object)))
+                (t
+                 (concat mixi-reply-to "diary")))))))
 
 (defconst mixi-to-regexp
   "^mixi;\\([a-z]+\\);?\\([a-z0-9]+\\)?;?\\([0-9]+\\)?;?\\([0-9]+\\)?")
diff --git a/mixi.el b/mixi.el
index 501d0a0..f748c6e 100644 (file)
--- a/mixi.el
+++ b/mixi.el
@@ -45,6 +45,7 @@
 ;;  * 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.183 $")
+(defconst mixi-revision "$Revision: 1.184 $")
 
 (defgroup mixi nil
   "API library for accessing to mixi."
@@ -3012,6 +3013,69 @@ Increase this value when unexpected error frequently occurs."
                                (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>&nbsp;<span STYLE=\"font-size:8pt;color:#DFB479\">¢£</span>&nbsp;<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)
 
 ;;; mixi.el ends here
index e6b04e5..4e78d12 100644 (file)
@@ -1,6 +1,6 @@
 ;;; sb-mixi.el --- shimbun backend for mixi
 
-;; Copyright (C) 2006, 2007 OHASHI Akira
+;; Copyright (C) 2006, 2007, 2008 OHASHI Akira
 
 ;; Author: OHASHI Akira <bg66@koka-in.org>
 ;; Keywords: news
 (require 'mixi-utils)
 (require 'shimbun)
 
-(defconst shimbun-mixi-revision "$Revision: 1.61 $")
+(defconst shimbun-mixi-revision "$Revision: 1.62 $")
 
 (eval-and-compile
-  (luna-define-class shimbun-mixi (shimbun) (comment-cache))
+  (luna-define-class shimbun-mixi (shimbun) (comment-cache release-cache))
   (luna-define-internal-accessors 'shimbun-mixi))
 
 (defconst shimbun-mixi-default-group-alist
        (mixi-get-news 'game-anime 'pickup range)))
     ("news.pickup.column" .
      (lambda (range)
-       (mixi-get-news 'column 'pickup range))))
+       (mixi-get-news 'column 'pickup range)))
+    ("releases" . mixi-get-releases))
   "An alist of mixi shimbun group default definition.")
 
 (defcustom shimbun-mixi-group-alist nil
@@ -157,10 +158,13 @@ of mixi object."
                                                &rest init-args)
   (shimbun-mixi-set-comment-cache-internal shimbun
                                           (make-hash-table :test 'equal))
+  (shimbun-mixi-set-release-cache-internal shimbun
+                                          (make-hash-table :test 'equal))
   shimbun)
 
 (luna-define-method shimbun-close :after ((shimbun shimbun-mixi))
   (shimbun-mixi-set-comment-cache-internal shimbun nil)
+  (shimbun-mixi-set-release-cache-internal shimbun nil)
   (mixi-logout))
 
 (luna-define-method shimbun-groups ((shimbun shimbun-mixi))
@@ -241,6 +245,21 @@ of mixi object."
          (setq comments (cdr comments)))))
     article))
 
+(defun shimbun-mixi-release-article (shimbun header)
+  (let* ((message-id (shimbun-header-id header))
+        (cache (shimbun-mixi-release-cache-internal shimbun))
+        (article (gethash message-id cache)))
+    (unless (stringp article)
+      (let* ((releases (mixi-get-releases)))
+       (while releases
+         (let ((id (mixi-make-message-id (car releases)))
+               (content (mixi-release-content (car releases))))
+           (puthash id content cache)
+           (when (string= id message-id)
+             (setq article content)))
+         (setq releases (cdr releases)))))
+    article))
+
 (luna-define-method shimbun-article ((shimbun shimbun-mixi)
                                     header &optional outbuf)
   (when (shimbun-current-group-internal shimbun)
@@ -249,10 +268,14 @@ of mixi object."
        (or (with-temp-buffer
             (let* ((url (shimbun-article-url shimbun header))
                    (object (mixi-make-object-from-url url))
-                   (article (if (string-match "#comment$" url)
-                                (shimbun-mixi-comment-article
-                                 url shimbun header)
-                              (mixi-make-content object))))
+                   (article (cond ((string-match "#comment$" url)
+                                   (shimbun-mixi-comment-article
+                                    url shimbun header))
+                                  ((string-match "release_info.pl$" url)
+                                   (shimbun-mixi-release-article
+                                    shimbun header))
+                                  (t
+                                   (mixi-make-content object)))))
               (mixi-make-reply-to object)
               (when (stringp article)
                 (insert article)))