def get_meta_data(self): structs = [ ('Video', self.player.video), ('Audio', self.player.audio), ('Other', self.player.metadata) ] meta = dict(self.player.metadata) result=['Metadata'] for name, struct in structs: tab = [] for i in struct: tab.append((i, struct[i])) result.append((name, tab)) meta = dict(self.player.metadata) tmp = [] if 'video-width' in meta: tmp.append(('Width', meta['video-width'])) if 'video-height' in meta: tmp.append(('Height', meta['video-height'])) if 'video-width' in meta and 'video-height' in meta: w = meta['video-width'] h = meta['video-height'] rw, rh = utils.reduce_fraction(w, h) tmp.append(('Ratio', '%d:%d (%.2f:1)' % (rw, rh, float(rw) / rh))) tmp.append(('MegaPixels', '%.2f' % (w * h / 1000000.0))) result.append(('Video', tmp)) return result
def testSimple(self): self.assertEquals(reduce_fraction(624, 352), (39, 22)) self.assertEquals(reduce_fraction(1920, 1080), (16, 9)) self.assertEquals(reduce_fraction(1920, 720), (8, 3))