]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/zoom.py
[extractor] Deprecate `_sort_formats`
[yt-dlp.git] / yt_dlp / extractor / zoom.py
index 6579f5ea4cd91fde41dd46751811bafb44559d3b..ef8b71522c11e79b1b7d0e0335c1d9c0eeefdea2 100644 (file)
@@ -1,15 +1,12 @@
-# coding: utf-8
-from __future__ import unicode_literals
-
-import re
-
 from .common import InfoExtractor
 from ..utils import (
     ExtractorError,
     int_or_none,
+    str_or_none,
     js_to_json,
     parse_filesize,
     urlencode_postdata,
+    urljoin,
 )
 
 
@@ -23,11 +20,12 @@ class ZoomIE(InfoExtractor):
             'id': 'dUk_CNBETmZ5VA2BwEl-jjakPpJ3M1pcfVYAPRsoIbEByGsLjUZtaa4yCATQuOL3der8BlTwxQePl_j0.EImBkXzTIaPvdZO5',
             'ext': 'mp4',
             'title': 'China\'s "two sessions" and the new five-year plan',
-        }
+        },
+        'skip': 'Recording requires email authentication to access',
     }
 
     def _real_extract(self, url):
-        base_url, play_id = re.match(self._VALID_URL, url).groups()
+        base_url, play_id = self._match_valid_url(url).groups()
         webpage = self._download_webpage(url, play_id)
 
         try:
@@ -55,14 +53,45 @@ def _real_extract(self, url):
             r'(?s)window\.__data__\s*=\s*({.+?});',
             webpage, 'data'), play_id, js_to_json)
 
+        subtitles = {}
+        for _type in ('transcript', 'cc', 'chapter'):
+            if data.get('%sUrl' % _type):
+                subtitles[_type] = [{
+                    'url': urljoin(base_url, data['%sUrl' % _type]),
+                    'ext': 'vtt',
+                }]
+
+        formats = []
+
+        if data.get('viewMp4Url'):
+            formats.append({
+                'format_note': 'Camera stream',
+                'url': str_or_none(data.get('viewMp4Url')),
+                'width': int_or_none(data.get('viewResolvtionsWidth')),
+                'height': int_or_none(data.get('viewResolvtionsHeight')),
+                'format_id': str_or_none(data.get('recordingId')),
+                'ext': 'mp4',
+                'filesize_approx': parse_filesize(data.get('fileSize')),
+                'preference': 0
+            })
+
+        if data.get('shareMp4Url'):
+            formats.append({
+                'format_note': 'Screen share stream',
+                'url': str_or_none(data.get('shareMp4Url')),
+                'width': int_or_none(data.get('shareResolvtionsWidth')),
+                'height': int_or_none(data.get('shareResolvtionsHeight')),
+                'format_id': str_or_none(data.get('shareVideoId')),
+                'ext': 'mp4',
+                'preference': -1
+            })
+
         return {
             'id': play_id,
-            'title': data['topic'],
-            'url': data['viewMp4Url'],
-            'width': int_or_none(data.get('viewResolvtionsWidth')),
-            'height': int_or_none(data.get('viewResolvtionsHeight')),
+            'title': data.get('topic'),
+            'subtitles': subtitles,
+            'formats': formats,
             'http_headers': {
                 'Referer': base_url,
             },
-            'filesize_approx': parse_filesize(data.get('fileSize')),
         }