# Copyright (C) 2009 Yukikaze
#import sys # モジュール属性 argv を取得するため
import os
-import configreader
-import tv2ts
import re
-import chdb
import time
-def write(pout,ch):
+import chdb
+import configreader
+import tv2ts
+import recdblist
+
+def write(pout, ch):
"""
tsを取得してepgの入ったxmlとして書き出す
"""
- print "ts2epg処理"
- bctype=chdb.chsearch(ch)['bctype']
- print ch+":"+bctype
- timet="120"
- if re.search('cs',bctype):
- mode="/CS"
- timet="300"
- elif re.search('bs',bctype):
- mode="/BS"
- timet="300"
- else :
- mode=chdb.bctypesearch('te'+ch)['ontv']
- tsepg2xml=configreader.getpath("tsepg2xml")
- time.sleep(5)
- tv2ts.tv2tsmix(pout+".ts",ch,"180")
- if not os.access(pout+".ts", os.F_OK):
- time.sleep(10)
- tv2ts.tv2tsmix(pout+".ts",ch,"180")
- exe="export LANG=ja_JP.UTF-8 && /usr/bin/nice -n 19 wine "+tsepg2xml+" "+mode+" "+pout+".ts >"+pout
- print exe
+ timet = "90"
+ if re.search(u'CS', ch):
+ timet = "180"
+ elif len(ch)>2:
+ timet = "240"
+ write_time(pout, ch ,timet)
+def write_time(pout, ch ,times):
+ """
+ 指定された時間分tsを取得してepgの入ったxmlとして書き出す
+ """
+ recdblist.printutf8(u"Ts-EPG XML書き出し処理開始")
+ recdblist.printutf8(u"CH:"+ch)
+ timet = times
+ if re.search(u'CS', ch):
+ mode = "/CS"
+ elif len(ch)>2:
+ mode = "/BS"
+ else:
+ mode = chdb.bctypesearch(u'te' + ch)['ontv']
+ epgdump = configreader.getpath("epgdump")
+ if os.access(pout + ".ts", os.F_OK):
+ os.remove(pout + ".ts")
+ time.sleep(10)
+ tv2ts.tv2tsmix(pout + ".ts", ch, timet)
+ exe = "export LANG=ja_JP.UTF-8 && nice -n 15 " + epgdump + " " + mode + " " + pout + ".ts " + pout
+ recdblist.printutf8(exe)
os.system(exe)
-
-
+ time.sleep(10)