Last active
December 27, 2015 07:49
-
-
Save zbryikt/7291803 to your computer and use it in GitHub Desktop.
ivod live status parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require! <[request iconv-lite]> | |
# return [menu-id, mms:ivod-id, title in asx] | |
# can be used to rebuild menu-id <-> ivod-id <-> title relationship | |
ivod-id-dynamic = -> | |
(e,r,b) <- request {url: "http://ivod.ly.gov.tw/vod/ch#it.asx", encoding: null}, _ | |
b = iconv-lite.decode b, \big5 | |
v = /mms:\/\/.+?\/ch(\d+)"/g.exec b | |
u = /Title>(.+?) .+?<\//g.exec b | |
console.log v.1, u.1 | |
[it, v.1, u.1] | |
ivod-id-hash = -> { | |
14: \YS #\院會 | |
10: \IAD #\內政 | |
11: \FND #\外交及國防 | |
8 : \ECO #\經濟 | |
1 : \FIN #\財政 | |
13: \EDU #\教育及文化 | |
9 : \TRA #\交通 | |
12: \JUD #\司法與法制 | |
6 : \SWE #\社會福利及衛生環境 | |
7 : \PRO #\程序 | |
}[it] | |
ivod-id = ivod-id-hash | |
live-status = (cb) -> | |
p = /menu_([a1])_(\d+)\.jpg/g | |
s = [] | |
(e,r,b) <- request \http://ivod.ly.gov.tw/new_live.jsp | |
while v = p.exec b => s.push [v.2, v.1==\a] | |
cb s | |
live-status -> | |
console.log(it.map(-> "#{ivod-id it.0}: #{if it.1 => \播放中 else \未開會}")join \\n) | |
it.map -> ivod-id-dynamic it.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
YS: 未開會 | |
IAD: 未開會 | |
FND: 未開會 | |
ECO: 未開會 | |
FIN: 未開會 | |
EDU: 未開會 | |
TRA: 未開會 | |
JUD: 未開會 | |
SWE: 未開會 | |
PRO: 未開會 | |
14 院會 | |
13 財政委員會 | |
11 外交及國防委員會 | |
8 經濟委員會 | |
10 內政委員會 | |
1 教育及文化委員會 | |
7 程序委員會 | |
12 司法及法制委員會 | |
6 社會福利及衛生環境委員會 | |
9 交通委員會 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment