OSDN Git Service

add Que system.
[rec10/rec10-git.git] / rec10 / trunk / src / recque.py
diff --git a/rec10/trunk/src/recque.py b/rec10/trunk/src/recque.py
new file mode 100644 (file)
index 0000000..1924a2f
--- /dev/null
@@ -0,0 +1,49 @@
+#!/usr/bin/python
+# coding: UTF-8
+# Rec10 TS Recording Tools
+# Copyright (C) 2009-2010 Yukikaze
+import datetime
+import os
+
+import configreader
+import recdblist
+import recdb
+def writeRecQue(parentpath,chtxt,title,opts):
+    f=open(os.path.join(parentpath,title+".recq"),"w")
+    optt=opts.replace("E","")
+    optt=optt.replace("D","")
+    optt=optt.replace("R","")
+    str="99"+","+datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")+","+configreader.getenv("iff")+","+chtxt+","+title+","+optt
+    f.write(str.encode('utf-8'))
+    f.close()
+
+def readRecQue(recquepath):
+    f=open(os.path.join(parentpath,title+".recq"),"r")
+    line = unicode(f.readline(),'utf-8')
+    title=""
+    opts=""
+    chtxt=""
+    while line:
+        linec=line.split(",")
+        if len(linec)>3:
+            if linec[0]=="99":
+                title=linec[4]
+                opts=linec[5]
+                chtxt=linec[2]+u"_"+linec[3]
+                break
+        line = unicode(f.readline(),'utf-8')
+    dbkey=""
+    if opts.find("E"):
+        dbkey=""
+        opts=opts.replace("E","")
+    if opts.find("D"):
+        dbkey=recdblist.REC_ENCODE_QUE
+        opts=opts.replace("D","")
+    if opts.find("R"):
+        dbkey=recdblist.REC_TS_DECODE_QUE
+        opts=opts.replace("E","")
+    bt=datetime.datetime.now()+datetime.timedelta(minutes=5)
+    et=bt+datetime.timedelta(minutes=30)
+    btime=bt.strftime("%Y-%m-%d %H:%M:%S")
+    etime=et.strftime("%Y-%m-%d %H:%M:%S")
+    recdb.rec_reckey(dbkey, title, chtxt, btime, etime, opts)