OSDN Git Service

fix rename miss.
[rec10/rec10-git.git] / rec10 / trunk / src / chdata.py
1 #!/usr/bin/python\r
2 # coding: UTF-8\r
3 # Rec10 TS Recording Tools\r
4 # Copyright (C) 2009-2010 Yukikaze\r
5 import os.path\r
6 import configreader\r
7 import xml.dom.minidom\r
8 \r
9 import rec10d\r
10 \r
11 path = str(os.path.dirname(os.path.abspath(__file__))) + "/"\r
12 \r
13 def chAdd(bctype, chtxt, ch, csch):#すべて文字列\r
14     rec10d.rec10db.add_epg_ch(bctype,chtxt, ch, csch, u"2010-01-01 00:00:00")\r
15 def addCHlist(cl):\r
16     if len(cl)>0:\r
17         for c in cl:\r
18             chAdd(c[0],c[1],c[2],c[3])\r
19 def newChdata(bs,cs):\r
20     rec10d.rec10db.new_epg_ch()\r
21     addCHlist(getCHlist(os.path.join(path,"chlist.xml")))\r
22     if bs==1:\r
23         #bs放送の設定 全国共通のはず\r
24         addCHlist(getCHlist(os.path.join(path,"chlist_bs.xml")))\r
25     if cs==1:\r
26         #CS放送(スカパーe2)主に基本パックに入ってるものを中心に\r
27         chlistadd(getChList(os.path.join(path,"chlist_cs.xml")))\r
28 def newChdataAll():\r
29     bs=0\r
30     cs=0\r
31     try:\r
32         bs=int(configreader.getConfEnv("bs"))\r
33         cs=int(configreader.getConfEnv("cs"))\r
34     except:\r
35         ""\r
36     newChdata(bs,cs)\r
37 def getChList(xmlpath):\r
38     dom=xml.dom.minidom.parse(file(xmlpath))\r
39     chlist=[]\r
40     for ch in dom.getElementsByTagName('channel'):\r
41         bctype=ch.getAttribute("bctype")\r
42         chd=ch.getAttribute("ch")\r
43         csch=ch.getAttribute("csch")\r
44         chtxt=ch.getAttribute("chtxt")\r
45         ontv=ch.getAttribute("ontvcode")\r
46         chlist.append([bctype,ontv,chtxt,chd,csch])\r
47     return chlist\r
48 if __name__ == "__main__":\r
49     newChdataAll()\r