def __init__(self, parent, id, title, mplayer): global server wx.Frame.__init__(self, parent, id, title, size=(900,600)) self.panel = wx.Panel(self) self.selected = None self.playing = False # Create the GUI self.create_menu() self.create_widgets(mplayer) # Bind the mplayer events self.Bind(mpc.EVT_MEDIA_STARTED, self.on_media_started) self.Bind(mpc.EVT_MEDIA_FINISHED, self.on_media_started) self.Bind(mpc.EVT_PROCESS_STARTED, self.on_process_started) self.Bind(mpc.EVT_PROCESS_STOPPED, self.on_process_stopped) # Get the info about the recordings from the MythTV backend try: self.conn = cmyth.connection(server) self.programs = self.conn.get_proglist() self.create_title_list() except: print 'connection failed' random.seed() self.server = media() self.server.daemon = True self.server.start()
def __init__(self, parent, id, title, mplayer): global server wx.Frame.__init__(self, parent, id, title, size=(900, 600)) self.panel = wx.Panel(self) self.selected = None self.playing = False # Create the GUI self.create_menu() self.create_widgets(mplayer) # Bind the mplayer events self.Bind(mpc.EVT_MEDIA_STARTED, self.on_media_started) self.Bind(mpc.EVT_MEDIA_FINISHED, self.on_media_started) self.Bind(mpc.EVT_PROCESS_STARTED, self.on_process_started) self.Bind(mpc.EVT_PROCESS_STOPPED, self.on_process_stopped) # Get the info about the recordings from the MythTV backend try: self.conn = cmyth.connection(server) self.programs = self.conn.get_proglist() self.create_title_list() except: print 'connection failed' random.seed() self.server = media() self.server.daemon = True self.server.start()
def init_server(self, new_server): global server if new_server != server: print 'switch from %s to %s' % (server, new_server) server = new_server self.title_box.Set([]) self.episode_box.Set([]) try: self.conn = cmyth.connection(server) self.programs = self.conn.get_proglist() self.create_title_list() except: print 'connection failed'
def test_file(host): conn = cmyth.connection(host) list = conn.get_proglist() prog = list.get_prog(0) file = prog.open() m = hashlib.md5() file.seek(0) for i in range(5): rc,buf = file.read() if rc < 0 or len(buf) == 0: print 'Error: file read failed!' break m.update(buf) print 'MD5: %s' % m.hexdigest()
def test_thumbnail(host): conn = cmyth.connection(host) list = conn.get_proglist() prog = list.get_prog(0) file = prog.open(cmyth.FILETYPE_THUMBNAIL) m = hashlib.md5() file.seek(0) size = 0 while True: rc,buf = file.read() if rc < 0 or len(buf) == 0: break m.update(buf) size += len(buf) print 'Thumbnail image size: %d' % size print 'MD5: %s' % m.hexdigest()
def test_host(host): conn = cmyth.connection(host) print 'Protocol version: %d' % conn.protocol_version() recorded = conn.get_proglist() pending = conn.get_proglist(cmyth.PROGTYPE_PENDING) scheduled = conn.get_proglist(cmyth.PROGTYPE_SCHEDULED) e = conn.get_event(0.1) if e: print 'Event: "%s" (%d) "%s"' % (e.name(), e.type(), e.message()) print 'Recording count: %d' % recorded.get_count() total = conn.storage_space_total() used = conn.storage_space_used() print 'Storage space total: %d used: %d' % (total, used) for i in range(recorded.get_count()): prog = recorded.get_prog(i) print ' %s - %s' % (prog.title(), prog.subtitle()) print ' %s %d' % (prog.pathname(), prog.length()) print ' %d - %d' % (prog.start(), prog.end()) print ' %s - %s' % (prog.start_str(), prog.end_str()) print ' %s - %s - %d' % (prog.channel_sign(), prog.channel_name(), prog.channel_id()) print ' %s' % prog.description() print 'Pending count: %d' % pending.get_count() for i in range(pending.get_count()): prog = pending.get_prog(i) print ' %s - %s' % (prog.title(), prog.subtitle()) print ' %s - %s' % (prog.start_str(), prog.end_str()) print ' %s - %s - %d' % (prog.channel_sign(), prog.channel_name(), prog.channel_id()) print 'Scheduled count: %d' % scheduled.get_count() for i in range(scheduled.get_count()): prog = scheduled.get_prog(i) print ' %s' % prog.title() if conn.hung(): print 'Connection is hung!'
def connect(): global conn global server global progs if conn: print "Reconnect to server %s" % server else: print "Connect to server %s" % server while True: try: conn = cmyth.connection(server) print "connection established" progs = conn.get_proglist() print "got program list with %d recordings" % progs.get_count() return except: print "connection failed!" time.sleep(1)
def test_perf(host): conn = cmyth.connection(host) list = conn.get_proglist() prog = list.get_prog(0) file = prog.open() file.seek(0) offset = 0 start = time.time() while offset < 67108864: rc,buf = file.read() if rc < 0 or len(buf) == 0: print 'Error: file read failed!' break offset += len(buf) end = time.time() duration = end - start mbps = (offset * 8) / duration / 1000000.0 print 'Perf: read %d bytes in %5.2f seconds (%5.2f mb/s)' % (offset, duration, mbps)
def main(): global verbose server = None filename = None dirname = None outdir = None output = None replace = False password = None try: opts, args = getopt.getopt(sys.argv[1:], "d:ho:p:rs:v", [ "database=", "help", "output=", "program=", "replace", "server=", 'verbose' ]) except getopt.GetoptError: usage(1) for o, a in opts: if o in ("-d", "--database"): password = a if o in ("-h", "--help"): usage(0) if o in ("-o", "--output"): outdir = a if o in ("-p", "--program"): filename = os.path.basename(a) dirname = os.path.dirname(a) if o in ("-r", "--replace"): replace = True if o in ("-s", "--server"): server = a if o in ("-v", "--verbose"): verbose = True if server == None: server = 'localhost' if filename == None: print 'Error: filename not provided!' sys.exit(-1) if dirname == '': dirname = os.getcwd() if outdir == None: if replace == True: outdir = dirname else: outdir = os.getcwd() output = '%s/%s.mp4' % (outdir, filename) conn = cmyth.connection(server) list = conn.get_proglist() count = list.get_count() for i in range(count): prog = list.get_prog(i) pathname = prog.pathname() if pathname[1:] == filename: transcode(prog, dirname, filename, output) add_chapters(prog, dirname, output) add_tags(prog, output) if replace == True: replace_original(dirname, filename, output, server, password)
def main(): global verbose try: opts, args = getopt.getopt(sys.argv[1:], 'c:ehio:ps:v', [ 'cat=', 'event', 'help', 'info', 'proglist', 'output=', 'server=', 'verbose' ]) except getopt.GetoptError: usage(1) conn = None server = None which = None output = None o_proglist = False o_info = False o_event = False for o, a in opts: if o in ('-c', '--cat'): which = a if o in ('-e', '--event'): o_event = True if o in ('-h', '--help'): usage(0) if o in ('-i', '--info'): o_info = True if o in ('-o', '--output'): output = a if o in ('-p', '--proglist'): o_proglist = True if o in ('-s', '--server'): server = a if o in ('-v', '--verbose'): verbose = True if server == None: print 'Error: server not specified!' usage(1) try: conn = cmyth.connection(server) except: print 'Could not connect to MythTV server at %s' % server sys.exit(-1) if which: try: do_cat(conn, int(which), output) except: print 'Failure detected!' sys.exit(-1) sys.exit(0) if o_info: do_info(conn) if o_proglist: do_proglist(conn, o_proglist) if o_event: do_event(conn)
def main(): global verbose try: opts, args = getopt.getopt(sys.argv[1:], 'c:ehio:ps:v', [ 'cat=', 'event', 'help', 'info', 'proglist', 'output=', 'server=', 'verbose' ]) except getopt.GetoptError: usage(1) conn = None server = None which = None output = None o_proglist = False o_info = False o_event = False for o, a in opts: if o in ('-c', '--cat'): which = a if o in ('-e', '--event'): o_event = True if o in ('-h', '--help'): usage(0) if o in ('-i', '--info'): o_info = True if o in ('-o', '--output'): output = a if o in ('-p', '--proglist'): o_proglist = True; if o in ('-s', '--server'): server = a if o in ('-v', '--verbose'): verbose = True if server == None: print 'Error: server not specified!' usage(1) try: conn = cmyth.connection(server) except: print 'Could not connect to MythTV server at %s' % server sys.exit(-1) if which: try: do_cat(conn, int(which), output) except: print 'Failure detected!' sys.exit(-1) sys.exit(0) if o_info: do_info(conn) if o_proglist: do_proglist(conn, o_proglist) if o_event: do_event(conn)