summary refs log tree commit diff
diff options
context:
space:
mode:
authorRemita Amine <remitamine@gmail.com>2019-11-30 15:50:17 +0100
committerRemita Amine <remitamine@gmail.com>2019-11-30 15:50:17 +0100
commit0b25af9bf5e044a3cb2c515574a00523a1b79a2b (patch)
treebe8f01ea49428ff503b7e4d442649e4e259fb2fd
parent8d3a3a9901fa8ffdef84add5107f54d9d37050f2 (diff)
downloadyoutube-dl-0b25af9bf5e044a3cb2c515574a00523a1b79a2b.tar.gz
youtube-dl-0b25af9bf5e044a3cb2c515574a00523a1b79a2b.tar.xz
youtube-dl-0b25af9bf5e044a3cb2c515574a00523a1b79a2b.zip
[tv2] detect DRM protection
-rw-r--r--youtube_dl/extractor/tv2.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/youtube_dl/extractor/tv2.py b/youtube_dl/extractor/tv2.py
index e8aaa2f14..4a19b9be6 100644
--- a/youtube_dl/extractor/tv2.py
+++ b/youtube_dl/extractor/tv2.py
@@ -79,9 +79,10 @@ class TV2IE(InfoExtractor):
                     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))
@@ -94,6 +95,8 @@ class TV2IE(InfoExtractor):
                         '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(
@@ -104,7 +107,7 @@ class TV2IE(InfoExtractor):
         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,