#!/usr/bin/python
# coding: UTF-8
# Rec10 TS Recording Tools
# Copyright (C) 2009 Yukikaze
import recdb
import sqlite3
import os
dbpath=str(os.path.dirname(os.path.abspath(__file__)))+"/"+"ch.db"
tasks=recdb.getall()
db=sqlite3.connect(dbpath)


print "チャンネルデータ"
for bctype, ontv, chtxt, ch, csch ,updatetime in db.execute("SELECT bctype,ontv,chtxt,ch,csch,updatetime FROM chdata"):
    print (bctype+","+ontv+","+chtxt+","+ch+","+csch+","+updatetime)
db.close()
print "録画予約"
for task in tasks:
        #value=line.split(",")
        if task["type"]=="res":#"res,"+chtxt+","+title+","+btime+","+etime+","+opt
            chtxt=task['chtxt']
            title=task['title']
            btime=task['btime']
            etime=task['etime']
            opt=task['opt']
            print "録画予約"+","+chtxt+","+title+","+btime+","+etime+","+opt
        elif task["type"]=="key":#"key,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt
            chtxt=task['chtxt']
            #title=task['title']
            btime=task['btime']
            #etime=task['etime']
            keyword=task['title']
            deltatime=task['deltatime']
            opt=task['opt']
            print "検索予約"+","+chtxt+","+keyword+","+btime+","+deltatime+","+opt
        elif task["type"]=="keyevery":#"keyevery,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt+","+deltaday
            chtxt=task['chtxt']
            #title=task['title']
            btime=task['btime']
            #etime=task['etime']
            keyword=task['title']
            deltatime=task['deltatime']
            opt=task['opt']			
            deltaday=task['deltaday']
            print "隔日予約"+","+chtxt+","+keyword+","+btime+","+deltatime+","+opt+","+deltaday
        elif task["type"]=="rec":#"rec,"+chtxt+","+title+","+btime+","+etime+","+opt
            chtxt=task['chtxt']
            title=task['title']
            print title
            btime=task['btime']
            etime=task['etime']
            #keyword=task['keyword']
            #deltatime==task['deltatime']
            opt=task['opt']
            print "予約最終"+","+chtxt+","+title+","+btime+","+etime+","+opt

