OSDN Git Service

implement personal epg updating(3).
authorgn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Mon, 24 Aug 2009 01:31:29 +0000 (01:31 +0000)
committergn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Mon, 24 Aug 2009 01:31:29 +0000 (01:31 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@129 4e526526-5e11-4fc0-8910-f8fd03428081

rec10/trunk/src/epgdb.py
rec10/trunk/src/timerec.py
rec10/trunk/src/xml2db.py

index 19aa4e4..6f0c433 100644 (file)
@@ -41,6 +41,7 @@ def updatebc(bctype):
         print type(inst)
         print inst
         xml2db.xml2db(tmppath+bctype+"epgdate.bak.xml",bctype)
+        rec10d.rec10db.update_status_by_bctype_chdata(bctype,"2")
 def updatebc_bak(bctype):
     """
     update epg data by .bak file
index d4926ee..ccfc705 100644 (file)
@@ -25,29 +25,38 @@ def task():
     recdb.delete_old("6")
     tasks=recdb.getnow("2")
     #print tasks
-    inum=recdb.countRecNow("1")
+    inum=recdb.countRecNow_minutes("10")
+    #inum=recdb.countRecNow("1")
     print "now-rectask"
     print "inum:"+str(inum)+"bscsrec:"+str(status.getBSCSRecording())+"terec:"+str(status.getTERecording())+" epg:"+str(status.getEPGUpdating())
 
-    if inum+status.getBSCSRecording()+status.getTERecording() < 2:
-        update=chdb.update()
-        print "番組表更新処理"
-        if len(update)>0:
-            pid=os.fork()
-            if pid!=0:
-                time.sleep(1)
-            else:
-                for bctype in update:
-                    i=0
+    #if inum+status.getBSCSRecording()+status.getTERecording() < 2:
+    update=chdb.update()
+    print "番組表更新処理"
+    if len(update)>0:
+        pid=os.fork()
+        if pid!=0:
+            time.sleep(1)
+        else:
+            i=0
+            for bctype in update:
+                recnum=0
+                if bctype.find('te')!=-1:
+                    recnum=status.getTERecording()+recdb.countRecNow_minutes_TE("10")
+                    print bctype+"//ing:"+str(status.getTERecording())+":task:"+str(recdb.countRecNow_minutes_TE("10"))
+                else:
+                    recnum=status.getBSCSRecording()+recdb.countRecNow_minutes_BSCS("10")
+                    print bctype+"//ing:"+str(status.getBSCSRecording())+":task:"+str(recdb.countRecNow_minutes_BSCS("10"))
+                if recnum < 2:
                     print update
                     rec10d.rec10db.update_status_by_bctype_chdata(bctype,"0")
                     epgdb.updatebc(bctype)
                     update=chdb.update()
-                    rec10d.rec10db.update_by_bctype_chdata(bctype)
-                    i=i+1
-                    if i>5:
-                        break
-                sys.exit()
+                    #rec10d.rec10db.update_by_bctype_chdata(bctype)
+                i=i+1
+                if i>1:
+                    break
+            sys.exit()
         """if len(update)>0 and status.getEPGUpdating()==0:
             #status.setEPGUpdating(1)
             print "番組表を更新"
@@ -100,14 +109,38 @@ def task():
         dt=dtt.days*24*60*60+dtt.seconds
         
         if task["type"]==recdb.REC_RESERVE:#"res,"+chtxt+","+title+","+btime+","+etime+","+opt
-            isUpdate=0
             print dt
             if (dt<58*60 and dt>20*60):
                 pid=os.fork()
                 if pid!=0:#親プロセスの場合
                     ""
                 else:#子プロセスの場合 アップデートを行って終了
-                    cht=chdb.chtxtsearch(chtxt)['bctype']
+                    bctypet=chdb.chtxtsearch(chtxt)['bctype']
+                    chdatat=rec10d.rec10db.select_by_bctype_chdata(bctypet)
+                    dt1=datetime.datetime.now()-datetime.datetime.strptime(chdatat[5],"%Y-%m-%d %H:%M:%S")
+                    dt1=dt1.days*24*60*60+dt1.seconds
+                    if dt1<60*60:
+                        recdata=epgdb.searchtime2(title.decode('utf-8'),btime,"5",chtxt)
+                        chtxtn=recdata[0]
+                        titlen=recdata[1]
+                        btimen=recdata[2]
+                        etimen=recdata[3]
+                        bt=datetime.datetime.strptime(btimen,"%Y-%m-%d %H:%M:%S")
+                        et=datetime.datetime.strptime(etimen,"%Y-%m-%d %H:%M:%S")
+                        btimen=bt.strftime("%Y-%m-%d %H:%M:%S")
+                        etimen=et.strftime("%Y-%m-%d %H:%M:%S")
+                        if chtxt!="":
+                            try:
+                                recdb.del_reckey(recdb.REC_RESERVE, title, chtxt, btime)
+                                recdb.rec_reckey(recdb.REC_FINAL_RESERVE, titlen, chtxtn, btimen, etimen, opt)
+                            except Exception,inst:
+                                print type(inst)
+                                print inst
+                        else:
+                            print "nothing match"
+                    else:
+                        rec10d.rec10db.update_status_by_bctype_chdata(bctypet,"3")
+                    """cht=chdb.chtxtsearch(chtxt)['bctype']
                     if cht.find('te')!=-1:
                         cht='te'
                     else:
@@ -161,7 +194,8 @@ def task():
                             print "nothing match"
                     else:
                         ""
-                    sys.exit()
+                    sys.exit()"""
+                    
             elif dt<=10*60:
                 try:
                     recdb.del_reckey(recdb.REC_RESERVE, title, chtxt, btime)
index 852b5e1..750d484 100644 (file)
@@ -19,7 +19,7 @@ def xml2db(xmlpath,bctypetemp):#bctypeは放送種別で'TE'(地デジ)BS,CSが
     global db,bctype
     bctype=bctypetemp
     #print path
-    createDB()
+    #createDB()
     #db.execute('drop table tv')
     #db.execute('drop table ch')
 
@@ -30,17 +30,21 @@ def xml2db(xmlpath,bctypetemp):#bctypeは放送種別で'TE'(地デジ)BS,CSが
     p.CharacterDataHandler=char_data
     parseDocument(p,xmlpath)
 
-def createDB():
+#def createDB():
+#    global bctype
+#    rec10d.rec10db.new_tv(bctype)
+#    rec10d.rec10db.new_ch(bctype)
+#def writetvDB(bctype,channel,start,stop,title,desc):#tvdateは(放送種別,チャンネル,start,stop,title,desc)の形式
+#    rec10d.rec10db.add_tv(bctype,channel,start,stop,title,desc)
+def writemultitvDB(tvlists):
     global bctype
     rec10d.rec10db.new_tv(bctype)
-    rec10d.rec10db.new_ch(bctype)
-def writetvDB(bctype,channel,start,stop,title,desc):#tvdateは(放送種別,チャンネル,start,stop,title,desc)の形式
-    rec10d.rec10db.add_tv(bctype,channel,start,stop,title,desc)
-def writemultitvDB(tvlists):
     rec10d.rec10db.add_multi_tv(tvlists)
-def writechDB(bctype,id,display):#tvdateは(チャンネル,display)の形式
-    rec10d.rec10db.add_ch(bctype,id,display)
+#def writechDB(bctype,id,display):#tvdateは(チャンネル,display)の形式
+#    rec10d.rec10db.add_ch(bctype,id,display)
 def writemultichDB(chlists):
+    global bctype
+    rec10d.rec10db.new_ch(bctype)
     rec10d.rec10db.add_multi_ch(chlists)
 def parseDocument(p,xmlfile):
     f=open(xmlfile,'r')
@@ -113,7 +117,3 @@ def char_data(data):
             xmldate[lastflag]+=data
     else:
         xmldate[lastflag]=data
-
-
-
-