9 for l in sys.stdin.readlines():
10 if l.startswith('<Metadata>'):
12 elif l.startswith('</Metadata'):
17 def note(k, v, highlight=None):
18 if highlight is not None and highlight(v):
19 print('%20s: %s' % (k, termcolor.colored(v, 'white', 'on_red')));
21 print('%20s: %s' % (k, v))
23 def bool_note(k, v, highlight=None):
24 v = 'yes' if v == 1 else 'no'
30 f = raw * dcp_rate / 96000.0
37 return '%s DCP_%02d:%02d:%02d.%02d' % (str(raw).ljust(8), h, m, s, f)
39 def content_time_from_frames(s, r):
48 return '%s Con_%02d:%02d:%02d.%02d' % (str(raw).ljust(8), h, m, s, f)
50 soup = bs4.BeautifulSoup(xml, 'xml')
51 note('Name', soup.Metadata.Name.text)
52 note('Container', soup.Metadata.Container.text)
53 note('J2K bandwidth', soup.Metadata.J2KBandwidth.text, lambda x: int(x) < 20000000 or int(x) > 235000000)
54 note('Video frame rate', soup.Metadata.VideoFrameRate.text, lambda x: int(x) not in [24, 25, 30])
55 dcp_rate = int(soup.Metadata.VideoFrameRate.text)
56 note('Audio channels', soup.Metadata.AudioChannels.text)
57 bool_note('3D', soup.Metadata.ThreeD.text, lambda x: not x)
58 bool_note('Encrypted', soup.Metadata.ThreeD.text, lambda x: not x)
59 reel_types = ['single', 'by-video', 'by-length']
60 note('Reel type', reel_types[int(soup.ReelType.text)])
61 for c in soup.Metadata.Playlist.children:
62 if isinstance(c, bs4.element.Tag):
64 note(' Type', c.Type.text)
65 note(' Position', dcp_time(c.Position))
67 note(' Video rate', c.VideoFrameRate.text)
68 note(' Video length', content_time_from_frames(c.VideoLength, float(c.VideoFrameRate.text)))
70 note(' Audio rate', c.AudioFrameRate.text)
71 bool_note(' Reference video', c.ReferenceVideo, lambda x: not x)
72 bool_note(' Reference audio', c.ReferenceAudio, lambda x: not x)
73 bool_note(' Reference subtitle', c.ReferenceSubtitle, lambda x: not x)