[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Yahoo TV



# 小ネタ

広瀬さんち(http://www.gentei.org/~yuuji/diary/2004/06/01/)を見て。

w3m-yahoo-tv-prefectures が本当の読み仮名になっていないのが気に
なるけど、weather まではなぁ。。。

# emacs-w3m で 24時間分を見ると表示にめちゃくちゃ時間がかかった
# のでパス。

-- 
白井秀行 (mailto:shirai@meadowy.org)


(defvar w3m-yahoo-tv-url "http://tv.yahoo.co.jp/vhf" "*URL of the Yahoo TV")
(defvar w3m-yahoo-tv-prefecture "tokyo" "*Prefecure of the Yahoo TV")
(defvar w3m-yahoo-tv-prefectures '("hokk (北海道)"
				   "aomori (青森)"
				   "iwate (岩手)"
				   "akita (秋田)"
				   "yamagata (山形)"
				   "miya (宮城)"
				   "fuku (福島)"
				   "tochigi (栃木)"
				   "gunma (群馬)"
				   "ibaraki (茨城)"
				   "tokyo (東京)"
				   "kanagawa (神奈川)"
				   "saitama (埼玉)"
				   "chiba (千葉)"
				   "niigata (新潟)"
				   "nagano (長野)"
				   "yamanasi (山梨)"
				   "sizu (静岡)"
				   "ishikawa (石川)"
				   "toyama (富山)"
				   "fukui (福井)"
				   "aichi (愛知)"
				   "gifu (岐阜)"
				   "mie (三重)"
				   "osaka (大阪)"
				   "hyougo (兵庫)"
				   "kyoto (京都)"
				   "wakayama (和歌山)"
				   "nara (奈良)"
				   "siga (滋賀)"
				   "okayama (岡山)"
				   "kagawa (香川)"
				   "tokusima (徳島)"
				   "ehime (愛媛)"
				   "kouchi (高知)"
				   "hirosima (広島)"
				   "tottori (鳥取)"
				   "shimane (島根)"
				   "yamagchi (山口)"
				   "fukuoka (福岡)"
				   "saga (佐賀)"
				   "kumamoto (熊本)"
				   "nagasaki (長崎)"
				   "oita (大分)"
				   "miyazaki (宮崎)"
				   "kagosima (鹿児島)"
				   "nawa (沖縄)"))

(defun w3m-yahoo-tv (&optional args)
  "Yahoo TV の現在の番組表を見る。'\\[universal-argument]' 付きだと外部 viewer で一日分表示。"
  (interactive "P")
  (or (featurep 'w3m) (require 'w3m))
  (if args
      (let ((ctime (decode-time (current-time)))
	    url)
	;; Emulate "--date '6 hours ago'" in Gnu date
	(setcar (nthcdr 2 ctime) (- (car (nthcdr 2 ctime)) 6))
	(setq ctime (apply 'encode-time ctime))
	(setq url (format "%s/%s/%s24.html"
			  w3m-yahoo-tv-url w3m-yahoo-tv-prefecture
			  (format-time-string "%Y%m%d" ctime)))
	(w3m-external-view url))
    (w3m-goto-url (format "%s/%s/realtime.html"
			  w3m-yahoo-tv-url w3m-yahoo-tv-prefecture))))

(defun w3m-yahoo-tv-prefecture (&optional args)
  "Yahoo TV の都道府県選択をしつつ表示"
  (interactive "P")
  (let* ((prefs (mapcar (lambda (x) (cons x x)) w3m-yahoo-tv-prefectures))
	 (prefecure (completing-read
		     (format "都道府県 (%s): " w3m-yahoo-tv-prefecture)
		     prefs nil t))
	 (w3m-yahoo-tv-prefecture w3m-yahoo-tv-prefecture))
    (when (or (null prefecure) (string= prefecure ""))
      (setq prefecure
	    (catch 'det
	      (while prefs
		(when (string-match (concat "^" w3m-yahoo-tv-prefecture " ")
				    (car (car prefs)))
		  (throw 'det (car (car prefs))))
		(setq prefs (cdr prefs))))))
    (when (and prefecure
	       (string-match "^\\([^ ]+\\) " prefecure))
      (setq w3m-yahoo-tv-prefecture (match-string 1 prefecure))
      (message "Now '%s'" prefecure))
    (w3m-yahoo-tv args)))