diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2015-01-30 16:00:47 +0100 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2015-01-30 16:00:47 +0100 |
commit | c7ff0c6422f2cae88e80bc286b3df391042fcb09 (patch) | |
tree | 178f498ce19dcd79bbce339ad28e7d4024c66838 /youtube_dl | |
parent | 01c46659c4aa312a6d7c935d3a92d9fa07d66c00 (diff) | |
parent | 6ca85be6f8697dc8cb0378854c2c6cdc154593d4 (diff) |
Merge remote-tracking branch 'rzhxeo/f4m-drm'
Diffstat (limited to 'youtube_dl')
-rw-r--r-- | youtube_dl/downloader/f4m.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/youtube_dl/downloader/f4m.py b/youtube_dl/downloader/f4m.py index c68b2c303..29de7630d 100644 --- a/youtube_dl/downloader/f4m.py +++ b/youtube_dl/downloader/f4m.py @@ -230,6 +230,23 @@ class F4mFD(FileDownloader): A downloader for f4m manifests or AdobeHDS. """ + def _get_unencrypted_media(self, doc): + media=doc.findall(_add_ns('media')) + if not media: + self.report_error('No media found') + for e in (doc.findall(_add_ns('drmAdditionalHeader')) + + doc.findall(_add_ns('drmAdditionalHeaderSet'))): + # If id attribute is missing it's valid for all media nodes + # without drmAdditionalHeaderId or drmAdditionalHeaderSetId attribute + if not 'id' in e.attrib: + self.report_error('Media is DRM protected') + media = list(filter(lambda e: 'drmAdditionalHeaderId' not in e.attrib and + 'drmAdditionalHeaderSetId' not in e.attrib, + media)) + if not media: + self.report_error('Media is DRM protected') + return media + def real_download(self, filename, info_dict): man_url = info_dict['url'] requested_bitrate = info_dict.get('tbr') @@ -248,7 +265,8 @@ class F4mFD(FileDownloader): ) doc = etree.fromstring(manifest) - formats = [(int(f.attrib.get('bitrate', -1)), f) for f in doc.findall(_add_ns('media'))] + formats = [(int(f.attrib.get('bitrate', -1)), f) + for f in self._get_unencrypted_media(doc)] if requested_bitrate is None: # get the best format formats = sorted(formats, key=lambda f: f[0]) |