OSDN Git Service

classify : fix DB id undefined.
[rec10/rec10-git.git] / rec10 / ts2epg.py
1 #!/usr/bin/python
2 # coding: UTF-8
3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2011 Yukikaze
5 #import sys # モジュール属性 argv を取得するため
6 import os
7 import re
8 import time
9 import commands
10
11 import chdb
12 import configreader
13 import tv2ts
14 import recdblist
15
16 def writeEpgXML(pout, ch):
17     """
18     tsを取得してepgの入ったxmlとして書き出す
19     """
20     timet = "90"
21     if re.search(u'CS', ch):
22         timet = "180"
23     elif len(ch)>2:
24         timet = "240"
25     writeEpgXMLTime(pout, ch ,timet)
26 def writeLogoEpgXML(pout, ch):
27     """
28     tsを取得してepgの入ったxmlとして書き出す
29     """
30     timet = "600"
31     if re.search(u'CS', ch):
32         timet = "10"
33     elif len(ch)>2:
34         timet = "1200"
35     writeEpgXMLTime(pout, ch ,timet,islogo=1)
36 def writeEpgXMLTime(pout, ch ,times,islogo=0):
37     """
38     指定された時間分tsを取得してepgの入ったxmlとして書き出す
39     """
40     if islogo==0:
41         recdblist.addCommonlogEX(u"通常","write_time(ts2epg.py)",u"Ts-EPG XML書き出し処理開始" ,u"CH:"+ch,log_level=500)
42     elif islogo==1:
43         recdblist.addCommonlogEX(u"通常","write_time(ts2epg.py)",u"Ts-EPG LOGO : XML書き出し処理開始" ,u"CH:"+ch,log_level=500)
44     timet = times
45     if re.search(u'CS', ch):
46         mode = "/CS"
47     elif len(ch)>2:
48         mode = "/BS"
49     else:
50         mode = str(chdb.searchCHFromBctype(u'te' + ch)['ch'])
51     epgdump = configreader.getConfPath("epgdump")
52     if os.access(pout + ".ts", os.F_OK):
53         os.remove(pout + ".ts")
54     time.sleep(10)
55     tv2ts.tv2b25ts(pout+ ".ts", ch, times,"0")
56     logoopt=""
57     if islogo==1:
58         logoopt="/LOGO "
59     os.chmod(pout+".ts",0755)
60     exe = "export LANG=ja_JP.UTF-8 && nice -n 15 " + epgdump + " " +logoopt+ mode + " " + pout + ".ts " + pout
61     recdblist.printutf8(exe)
62     recdblist.addCommonlogEX(u"通常", "write_time(ts2epg.py) "+str(ch), exe,"",log_level=500)
63     unicode(commands.getoutput(exe),'utf-8','ignore')
64     time.sleep(10)
65     if os.path.exists(pout+".ts"):
66         os.remove(pout+ ".ts")
67