forked from openlp/openlp
parent
3560b27bfb
commit
ab810734d8
|
@ -100,34 +100,12 @@ class MediaInfoWrapper(object):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse(filename, environment=ENV_DICT):
|
def parse(filename, environment=ENV_DICT):
|
||||||
if MediaInfoWrapper._version():
|
xml = check_output(['mediainfo', '-f', '--Output=XML', '--Inform=OLDXML', filename])
|
||||||
format = 'OLDXML'
|
if not xml.startswith(b'<?xml'):
|
||||||
else:
|
xml = check_output(['mediainfo', '-f', '--Output=XML', filename])
|
||||||
format = 'XML'
|
xml_dom = MediaInfoWrapper.parse_xml_data_into_dom(xml)
|
||||||
command = ["mediainfo", "-f", "--Output={format}".format(format=format), filename]
|
|
||||||
fileno_out, fname_out = mkstemp(suffix=".xml", prefix="media-")
|
|
||||||
fileno_err, fname_err = mkstemp(suffix=".err", prefix="media-")
|
|
||||||
fp_out = os.fdopen(fileno_out, 'r+b')
|
|
||||||
fp_err = os.fdopen(fileno_err, 'r+b')
|
|
||||||
p = Popen(command, stdout=fp_out, stderr=fp_err, env=environment)
|
|
||||||
p.wait()
|
|
||||||
fp_out.seek(0)
|
|
||||||
|
|
||||||
xml_dom = MediaInfoWrapper.parse_xml_data_into_dom(fp_out.read())
|
|
||||||
fp_out.close()
|
|
||||||
fp_err.close()
|
|
||||||
os.unlink(fname_out)
|
|
||||||
os.unlink(fname_err)
|
|
||||||
return MediaInfoWrapper(xml_dom)
|
return MediaInfoWrapper(xml_dom)
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _version():
|
|
||||||
# For now we're only intrested in knowing the new style version (yy.mm)
|
|
||||||
version_str = check_output(['mediainfo', '--version'])
|
|
||||||
return re.search(b'\d\d\.\d\d', version_str)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _populate_tracks(self):
|
def _populate_tracks(self):
|
||||||
if self.xml_dom is None:
|
if self.xml_dom is None:
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue