* Added `shimbun' feature (EXPERIMENTAL).
[elisp/wanderlust.git] / elmo / sb-sponichi.el
1 ;;; sb-sponichi.el --- shimbun backend for www.sponichi.co.jp
2
3 ;; Author: TSUCHIYA Masatoshi <tsuchiya@pine.kuee.kyoto-u.ac.jp>
4 ;;         Akihiro Arisawa    <ari@atesoft.advantest.co.jp>
5 ;;         Yuuichi Teranishi <teranisi@gohome.org>
6
7 ;; Keywords: news
8
9 ;;; Copyright:
10
11 ;; This program is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with this program; if not, you can either send email to this
23 ;; program's maintainer or write to: The Free Software Foundation,
24 ;; Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
25
26 ;;; Commentary:
27
28 ;; Original code was nnshimbun.el written by
29 ;; TSUCHIYA Masatoshi <tsuchiya@pine.kuee.kyoto-u.ac.jp>.
30
31 ;;; Code:
32
33 (require 'shimbun)
34 (require 'sb-text)
35
36 (luna-define-class shimbun-sponichi (shimbun shimbun-text) ())
37
38 (defvar shimbun-sponichi-url "http://www.sponichi.co.jp/")
39 (defvar shimbun-sponichi-groups '("baseball" "soccer" "usa" "others"
40                                   "society" "entertainment" "horseracing"))
41 (defvar shimbun-sponichi-coding-system (static-if (boundp 'MULE)
42                                            '*sjis* 'shift_jis))
43 (defvar shimbun-sponichi-from-address "webmaster@www.sponichi.co.jp")
44 (defvar shimbun-sponichi-content-start "\n<span class=\"text\">\e$B!!\e(B")
45 (defvar shimbun-sponichi-content-end "\n")
46
47 (luna-define-method shimbun-index-url ((shimbun shimbun-sponichi))
48   (format "%s%s/index.html"
49           (shimbun-url-internal shimbun)
50           (shimbun-current-group-internal shimbun)))
51
52 (luna-define-method shimbun-get-headers ((shimbun shimbun-sponichi))
53   (when (search-forward "\e$B%K%e!<%9%$%s%G%C%/%9\e(B" nil t)
54     (delete-region (point-min) (point))
55     (when (search-forward "\e$B%"%I%?%0\e(B" nil t)
56       (forward-line 2)
57       (delete-region (point) (point-max))
58       (goto-char (point-min))
59       (let ((case-fold-search t)
60             headers)
61         (while (re-search-forward
62                 "^<a href=\"/\\(\\([A-z]*\\)/kiji/\\([0-9][0-9][0-9][0-9]\\)/\\([0-9][0-9]\\)/\\([0-9][0-9]\\)/\\([0-9][0-9]\\)\\.html\\)\">"
63                 nil t)
64           (let ((url (match-string 1))
65                 (id (format "<%s%s%s%s%%%s>"
66                             (match-string 3)
67                             (match-string 4)
68                             (match-string 5)
69                             (match-string 6)
70                             (shimbun-current-group-internal shimbun)))
71                 (date (shimbun-make-date-string
72                        (string-to-number (match-string 3))
73                        (string-to-number (match-string 4))
74                        (string-to-number (match-string 5)))))
75             (push (shimbun-make-header
76                    0
77                    (shimbun-mime-encode-string
78                     (mapconcat 'identity
79                                (split-string
80                                 (buffer-substring
81                                  (match-end 0)
82                                  (progn (search-forward "<br>" nil t) (point)))
83                                 "<[^>]+>")
84                                ""))
85                    (shimbun-from-address-internal shimbun)
86                    date id "" 0 0 (concat (shimbun-url-internal shimbun)
87                                           url))
88                   headers)))
89         headers))))
90
91 (provide 'sb-sponichi)
92
93 ;;; sb-sponichi.el ends here