File: sb-japantimes.el

package info (click to toggle)
w3m-el 1.4.569%2B0.20170110-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,780 kB
  • sloc: lisp: 45,666; sh: 515; makefile: 403
file content (118 lines) | stat: -rw-r--r-- 3,429 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
;;; sb-japantimes.el --- shimbun backend for www.japantimes.co.jp

;; Author: Hidetaka Iwai <tyuyu@mb6.seikyou.ne.jp>,
;;         KASUGA Toru <gen@qb3.so-net.ne.jp>

;; Keywords: news

;;; Copyright:

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.

;;; Commentary:

;; Original code was nnshimbun.el written by
;; TSUCHIYA Masatoshi <tsuchiya@namazu.org>.

;;; Code:

(require 'shimbun)

(luna-define-class shimbun-japantimes (shimbun) ())

(defvar shimbun-japantimes-url
  "http://www.japantimes.co.jp/")
(defvar shimbun-japantimes-groups
  '("general" "business"))
(defvar shimbun-japantimes-from-address
  "webmaster@japantimes.co.jp")
(defvar shimbun-japantimes-content-start
  "<div id=\"deck\">\\|<div id=\"mainbody\">")
(defvar shimbun-japantimes-content-end
  "^</div>")

(defvar shimbun-japantimes-group-table
  '(("general" "news.htm" "nn")
    ("business" "news.htm" "nb")))
(defvar shimbun-japantimes-expiration-days 7)

(luna-define-method shimbun-index-url ((shimbun shimbun-japantimes))
  (concat (shimbun-url-internal shimbun)
	  (nth 1 (assoc (shimbun-current-group-internal shimbun)
			shimbun-japantimes-group-table))))

(luna-define-method shimbun-get-headers ((shimbun shimbun-japantimes)
					 &optional range)
  (let ((regexp
	 (format
	  (eval-when-compile
	    (let ((s0 "[\t\n ]*")
		  (s1 "[\t\n ]+"))
	      (concat "<a href=\""
		      ;; 1. url
		      "\\(http://search.japantimes.co.jp/cgi-bin/"
		      ;; 2.
		      "\\(%s\\)"
		      ;; 3. year
		      "\\(20[0-9][0-9]\\)"
		      s0
		      ;; 4. month
		      "\\([0-1][0-9]\\)"
		      s0
		      ;; 5. day
		      "\\([0-3][0-9]\\)"
		      s0
		      ;; 6. tag
		      "\\([a-z][0-9]\\)"
		      s0 "\\.html\\)\">"
		      ;; 7. subject
		      s0 "\\([^[<>]+\\)"
		      s0 "</a>")))
	  (nth 2 (assoc (shimbun-current-group-internal shimbun)
			shimbun-japantimes-group-table))))
	(case-fold-search t)
	url serial year month day tag subject id date headers)
    (goto-char (point-min))
    (while (re-search-forward regexp nil t)
      (setq url (match-string 1)
	    serial (match-string 2)
	    year (match-string 3)
	    month (match-string 4)
	    day (match-string 5)
	    tag (match-string 6)
	    subject (match-string 7)
	    id (format "<%s%s%s%s%s%%%s.japantimes.co.jp>"
		       serial
		       year
		       month
		       day
		       tag
		       (shimbun-current-group-internal shimbun))
	    date (shimbun-make-date-string
		  (string-to-number year)
		  (string-to-number month)
		  (string-to-number day)))
      (push (shimbun-make-header
	     0
	     (shimbun-mime-encode-string subject)
	     (shimbun-from-address shimbun)
	     date id "" 0 0 url)
	    headers))
    headers))

(provide 'sb-japantimes)

;;; sb-japantimes.el ends here