Commit 58419a35 authored by Priscila Manhaes's avatar Priscila Manhaes

implemented getMetadata for ffmpeg, and test for it

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@44830 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d6652ff1
......@@ -75,10 +75,21 @@ class Handler(object):
def getMetadata(self, base_document=False):
"""Returns a dictionary with all metadata of the video.
Keywords Arguments:
base_document -- Boolean variable. if true, the video is also returned
along with the metadata."""
raise NotImplementedError
Keywords Arguments:"""
command = ["ffprobe",self.input.getUrl()]
stdout, stderr = Popen(command,
stdout=PIPE,
stderr=PIPE,
close_fds=True,
env=self.environment).communicate()
metadata = stderr.split('Metadata:')[1].split('\n')
metadata_dict = {}
for data in metadata:
if len(data) != 0:
key, value = data.split(':')
metadata_dict[key.strip()] = value.strip()
self.input.trash()
return metadata_dict
def setMetadata(self, metadata={}):
"""Returns a document with new metadata.
......
......@@ -47,7 +47,8 @@ class TestHandler(HandlerTestCase):
def testgetMetadata(self):
"""Test if metadata is extracted from"""
self.assertRaises(NotImplementedError, self.input.getMetadata)
output_metadata = self.input.getMetadata()
self.assertEquals(output_metadata, {'ENCODER': 'Lavf52.64.2'})
def testsetMetadata(self):
""" Test if metadata are inserted correclty """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment