[downloader/f4m] Extract routine for removing unsupported encrypted media

This commit is contained in:
Sergey M․ 2016-03-27 07:41:19 +06:00
parent 19dbaeece3
commit f7df343b4a

View File

@ -223,6 +223,12 @@ def write_metadata_tag(stream, metadata):
write_unsigned_int(stream, FLV_TAG_HEADER_LEN + len(metadata)) write_unsigned_int(stream, FLV_TAG_HEADER_LEN + len(metadata))
def remove_encrypted_media(media):
return list(filter(lambda e: 'drmAdditionalHeaderId' not in e.attrib and
'drmAdditionalHeaderSetId' not in e.attrib,
media))
def _add_ns(prop): def _add_ns(prop):
return '{http://ns.adobe.com/f4m/1.0}%s' % prop return '{http://ns.adobe.com/f4m/1.0}%s' % prop
@ -244,9 +250,7 @@ def _get_unencrypted_media(self, doc):
# without drmAdditionalHeaderId or drmAdditionalHeaderSetId attribute # without drmAdditionalHeaderId or drmAdditionalHeaderSetId attribute
if 'id' not in e.attrib: if 'id' not in e.attrib:
self.report_error('Missing ID in f4m DRM') self.report_error('Missing ID in f4m DRM')
media = list(filter(lambda e: 'drmAdditionalHeaderId' not in e.attrib and media = remove_encrypted_media(media)
'drmAdditionalHeaderSetId' not in e.attrib,
media))
if not media: if not media:
self.report_error('Unsupported DRM') self.report_error('Unsupported DRM')
return media return media