OSDN Git Service

the first release of 0.5
[rec10/rec10-git.git] / rec10 / branches / 0.5 / src / ts2epg.py
1 #!/usr/bin/python
2 # coding: UTF-8
3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
5 #import sys # モジュール属性 argv を取得するため
6 import os
7 import configreader
8 import tv2ts
9 import re
10 import chdb
11 import time
12
13 def write(pout,ch):
14     """
15     tsを取得してepgの入ったxmlとして書き出す
16     """
17     print "ts2epg処理"
18     bctype=chdb.chsearch(ch)['bctype']
19     print ch+":"+bctype
20     timet="180"
21     if re.search(u'cs',bctype):
22         mode="/CS"
23         timet="180"
24     elif re.search(u'bs',bctype):
25         mode="/BS"
26         timet="180"
27     else :
28         mode=chdb.bctypesearch(u'te'+ch)['ontv']
29     epgdump=configreader.getpath("epgdump")
30     if os.access(pout+".ts", os.F_OK):
31         os.remove(pout+".ts")
32     time.sleep(10)
33     print type(ch)
34     print ch
35     tv2ts.tv2tsmix(pout+".ts",ch,timet)
36     t=0
37     while not os.access(pout+".ts", os.F_OK):
38         time.sleep(10)
39         tv2ts.tv2tsmix(pout+".ts",ch,timet)
40         t=t+1
41         if t>10:
42             break
43     exe="export LANG=ja_JP.UTF-8 && /usr/bin/nice -n 15 "+epgdump+" "+mode+" "+pout+".ts "+pout
44     print exe
45     os.system(exe)
46     time.sleep(10)
47         
48