OSDN Git Service

implement update(to 0.9.10)
[rec10/rec10-git.git] / rec10 / trunk / src / timerec.py
index f9fe0e0..bae739b 100644 (file)
@@ -37,6 +37,11 @@ def task():
     try:
         if rec10d.rec10db.select_installed_in_status()==0 or rec10d.rec10db.select_version_in_status()<recdblist.version:
             install.install()
+        elif rec10d.rec10db.select_installed_in_status()==1:
+            import scan_ch
+            rec10d.rec10db.new_epg_ch()
+            scan_ch.searchCh()
+            rec10d.rec10db.change_chscaned_in_status()
     except:
         install.install()
     recdb.delete_old("24")
@@ -249,7 +254,7 @@ def task():
 def search_keyword(key):
     tnow = datetime.datetime.now()
     nows =tnow.strftime("%Y-%m-%d %H:%M:%S")
-    for k in key:
+    for k,auto,opt in key:
         recdatum = epgdb.searchtime_auto(k,nows, "144")
         for recdata in recdatum:
             if recdata[1] != "":
@@ -261,8 +266,11 @@ def search_keyword(key):
                 ett = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
                 btimet = btt.strftime("%Y-%m-%d %H:%M:%S")
                 etimet = ett.strftime("%Y-%m-%d %H:%M:%S")
-                if status.getSettings_auto_jbk()==1:
-                    topt=status.getSettings_auto_opt()
+                #if status.getSettings_auto_jbk()==1:
+                if auto==1 or status.getSettings_auto_jbk()==1:
+                    topt=opt
+                    if len(topt)==0:
+                        topt=status.getSettings_auto_opt()
                     try:
                         maxnum=0
                         if len(ch['ch'])>2:
@@ -272,8 +280,8 @@ def search_keyword(key):
                             maxnum=epgdb.count_schedule_timeline(btimet, etimet)[0]
                             maxnum=int(configreader.getenv("te_max"))-maxnum
                         if maxnum>0:
-                            topt=status.getSettings_auto_opt()
-                            recdb.recreserv(titlet,chtxtt, btimet, etimet,topt)
+                            if recdb.checkduplicate(titlet, chtxtt, btimet, etimet)==0:
+                                recdb.recreserv(titlet,chtxtt, btimet, etimet,topt)
                     except Exception, inst:
                         recdblist.Commonlogex("Error", "search_keyword_auto_jbk(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
                 else:
@@ -294,7 +302,7 @@ def type_reserve(typetxt,chtxt,title,bt,et,opt):
     if (dt < 58 * 60 and dt > 30 * 60):
         bctypet = chdb.chtxtsearch(chtxt)['bctype']
         chdatat = rec10d.rec10db.select_by_bctype_epg_ch(bctypet)
-        dt1 = datetime.datetime.strptime(chdatat[0][5], "%Y-%m-%d %H:%M:%S")-datetime.datetime.now()
+        dt1 = datetime.datetime.strptime(chdatat[0][4], "%Y-%m-%d %H:%M:%S")-datetime.datetime.now()
         dt1 = dt1.days * 24 * 60 * 60 + dt1.seconds
         if dt1 < 60 * 60:
             recdata = epgdb.searchtime2(title, btime, "5", chtxt)
@@ -322,7 +330,7 @@ def type_reserve(typetxt,chtxt,title,bt,et,opt):
             else:
                 recdblist.printutf8(u"追いかけ機能エラー:番組データが見付かりません。")
         else:
-            if rec10d.rec10db.select_by_bctype_epg_ch(bctypet)[0][6] != "0":
+            if rec10d.rec10db.select_by_bctype_epg_ch(bctypet)[0][5] != "0":
                 rec10d.rec10db.update_status_by_bctype_epg_ch(bctypet, "3")
         sys.exit()
     elif (dt <= 30 * 60 and dt > 20 * 60):
@@ -407,9 +415,15 @@ def type_final(typetxt,chtxt,title,bt,et,opt):
                     shutil.copy(os.path.join(recpath,title+".ts.b25"), os.path.join(movepath,title+".ts.b25"))
                 except:
                     ""
-                os.chmod(os.path.join(movepath,title+".ts.b25"),0777)
+                try:
+                    os.chmod(os.path.join(movepath,title+".ts.b25"),0777)
+                except:
+                    ""
                 recque.writeRecQue(movepath, chtxt, title, opt)
-                os.chmod(os.path.join(movepath,title+".recq"),0777)
+                try:
+                    os.chmod(os.path.join(movepath,title+".recq"),0777)
+                except:
+                    ""
             except Exception, inst:
                 recdblist.Commonlogex("Error", "Move option(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
             recdb.rec_reckey(recdblist.REC_MOVE_END, newtitle, chtxt, btime, etime, opt)
@@ -538,9 +552,15 @@ def type_decode_que(typetxt,chtxt,title,bt,et,opt):
                         shutil.copy(os.path.join(recpath,title+".ts"), os.path.join(movepath,title+".ts"))
                     except:
                         ""
-                    os.chmod(os.path.join(movepath,title+".ts"),0777)
+                    try:
+                        os.chmod(os.path.join(movepath,title+".ts"),0777)
+                    except:
+                        ""
                     recque.writeRecQue(movepath, chtxt, title, opt)
-                    os.chmod(os.path.join(movepath,title+".recq"),0777)
+                    try:
+                        os.chmod(os.path.join(movepath,title+".recq"),0777)
+                    except:
+                        ""
                     time.sleep(5)
                     if os.path.getsize(os.path.join(recpath,title+".ts"))==os.path.getsize(os.path.join(movepath,title+".ts")):
                         os.remove(os.path.join(recpath,title+".ts"))
@@ -613,8 +633,6 @@ def type_encode_que(typetxt,chtxt,title,bt,et,opt):
                     tv2mkv.ts2mkv(pin, pout, opt)
                 if re.search("8", opt) or re.search("9", opt):
                     optt=opt
-                    optt=optt.replace("8","MW8")
-                    optt=optt.replace("9","MW9")
                     poutt = recpath + "/" + "m_"+title + ".mp4"
                     if re.search("d", opt) or re.search("5", opt):
                         if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
@@ -632,8 +650,6 @@ def type_encode_que(typetxt,chtxt,title,bt,et,opt):
                     shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
             else:
                 optt=opt
-                optt=optt.replace("8","MW8")
-                optt=optt.replace("9","MW9")
                 poutt = recpath + "/" + "m_"+title + ".mp4"
                 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
                 if re.search("d", opt) or re.search("5", opt):
@@ -658,17 +674,29 @@ def type_encode_que(typetxt,chtxt,title,bt,et,opt):
                             shutil.copy(os.path.join(recpath,title+".mp4"), os.path.join(movepath,title+".mp4"))
                         except:
                             ""
-                        os.chmod(os.path.join(movepath,title+".mp4"),0777)
+                        try:
+                            os.chmod(os.path.join(movepath,title+".mp4"),0777)
+                        except:
+                            ""
                         recque.writeRecQue(movepath, chtxt, title, opt)
-                        os.chmod(os.path.join(movepath,title+".recq"),0777)
+                        try:
+                            os.chmod(os.path.join(movepath,title+".recq"),0777)
+                        except:
+                            ""
                     elif os.path.exists(os.path.join(recpath,title+".mkv")):
                         try:
                             shutil.copy(os.path.join(recpath,title+".mkv"), os.path.join(movepath,title+".mkv"))
                         except:
                             ""
-                        os.chmod(os.path.join(movepath,title+".mkv"),0777)
+                        try:
+                            os.chmod(os.path.join(movepath,title+".mkv"),0777)
+                        except:
+                            ""
                         recque.writeRecQue(movepath, chtxt, title, opt)
-                        os.chmod(os.path.join(movepath,title+".recq"),0777)
+                        try:
+                            os.chmod(os.path.join(movepath,title+".recq"),0777)
+                        except:
+                            ""
                 except Exception, inst:
                     errtxt1="move mkv/mp4 error."
                     errtxt2=str(type(inst))+"\n"