Skip to content

Commit

Permalink
[tv2] detect DRM protection
Browse files Browse the repository at this point in the history
  • Loading branch information
remitamine committed Nov 30, 2019
1 parent 8d3a3a9 commit 0b25af9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions youtube_dl/extractor/tv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ def _real_extract(self, url):
formats.extend(self._extract_f4m_formats(
video_url, video_id, f4m_id=format_id, fatal=False))
elif ext == 'm3u8':
formats.extend(self._extract_m3u8_formats(
video_url, video_id, 'mp4', entry_protocol='m3u8_native',
m3u8_id=format_id, fatal=False))
if not data.get('drmProtected'):
formats.extend(self._extract_m3u8_formats(
video_url, video_id, 'mp4', entry_protocol='m3u8_native',
m3u8_id=format_id, fatal=False))
elif ext == 'mpd':
formats.extend(self._extract_mpd_formats(
video_url, video_id, format_id, fatal=False))
Expand All @@ -94,6 +95,8 @@ def _real_extract(self, url):
'tbr': int_or_none(item.get('bitrate')),
'filesize': int_or_none(item.get('fileSize')),
})
if not formats and data.get('drmProtected'):
raise ExtractorError('This video is DRM protected.', expected=True)
self._sort_formats(formats)

asset = self._download_json(
Expand All @@ -104,7 +107,7 @@ def _real_extract(self, url):
thumbnails = [{
'id': thumbnail.get('@type'),
'url': thumbnail.get('url'),
} for _, thumbnail in asset.get('imageVersions', {}).items()]
} for _, thumbnail in (asset.get('imageVersions') or {}).items()]

return {
'id': video_id,
Expand Down

0 comments on commit 0b25af9

Please sign in to comment.