]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/cbs.py
[extractor] Deprecate `_sort_formats`
[yt-dlp.git] / yt_dlp / extractor / cbs.py
index ed5dc84a761640ddfe753095b19891fee5baa161..9aacd50c4565fe75bc43437dc695e96a3fb41ae5 100644 (file)
@@ -1,5 +1,3 @@
-from __future__ import unicode_literals
-
 from .theplatform import ThePlatformFeedIE
 from ..utils import (
     ExtractorError,
@@ -12,7 +10,7 @@
 )
 
 
-class CBSBaseIE(ThePlatformFeedIE):
+class CBSBaseIE(ThePlatformFeedIE):  # XXX: Do not subclass from concrete IE
     def _parse_smil_subtitles(self, smil, namespace=None, subtitles_lang='en'):
         subtitles = {}
         for k, ext in [('sMPTE-TTCCURL', 'tt'), ('ClosedCaptionURL', 'ttml'), ('webVTTCaptionURL', 'vtt')]:
@@ -54,7 +52,6 @@ def _extract_common_video_info(self, content_id, asset_types, mpx_acc, extra_inf
             subtitles = self._merge_subtitles(subtitles, tp_subtitles)
         if last_e and not formats:
             self.raise_no_formats(last_e, True, content_id)
-        self._sort_formats(formats)
 
         extra_info.update({
             'id': content_id,
@@ -77,21 +74,21 @@ class CBSIE(CBSBaseIE):
         (?:
             cbs:|
             https?://(?:www\.)?(?:
-                cbs\.com/(?:shows/[^/]+/video|movies/[^/]+)/|
+                cbs\.com/(?:shows|movies)/(?:video|[^/]+/video|[^/]+)/|
                 colbertlateshow\.com/(?:video|podcasts)/)
         )(?P<id>[\w-]+)'''
 
     # All tests are blocked outside US
     _TESTS = [{
-        'url': 'https://www.cbs.com/shows/garth-brooks/video/_u7W953k6la293J7EPTd9oHkSPs6Xn6_/connect-chat-feat-garth-brooks/',
+        'url': 'https://www.cbs.com/shows/video/xrUyNLtl9wd8D_RWWAg9NU2F_V6QpB3R/',
         'info_dict': {
-            'id': '_u7W953k6la293J7EPTd9oHkSPs6Xn6_',
+            'id': 'xrUyNLtl9wd8D_RWWAg9NU2F_V6QpB3R',
             'ext': 'mp4',
-            'title': 'Connect Chat feat. Garth Brooks',
-            'description': 'Connect with country music singer Garth Brooks, as he chats with fans on Wednesday November 27, 2013. Be sure to tune in to Garth Brooks: Live from Las Vegas, Friday November 29, at 9/8c on CBS!',
-            'duration': 1495,
-            'timestamp': 1385585425,
-            'upload_date': '20131127',
+            'title': 'Tough As Nails - Dreams Never Die',
+            'description': 'md5:a3535a62531cdd52b0364248a2c1ae33',
+            'duration': 2588,
+            'timestamp': 1639015200,
+            'upload_date': '20211209',
             'uploader': 'CBSI-NEW',
         },
         'params': {
@@ -99,14 +96,14 @@ class CBSIE(CBSBaseIE):
             'skip_download': True,
         },
     }, {
-        'url': 'https://www.cbs.com/shows/the-late-show-with-stephen-colbert/video/60icOhMb9NcjbcWnF_gub9XXHdeBcNk2/the-late-show-6-23-21-christine-baranski-joy-oladokun-',
+        'url': 'https://www.cbs.com/shows/video/sZH1MGgomIosZgxGJ1l263MFq16oMtW1/',
         'info_dict': {
-            'id': '60icOhMb9NcjbcWnF_gub9XXHdeBcNk2',
-            'title': 'The Late Show - 6/23/21 (Christine Baranski, Joy Oladokun)',
-            'timestamp': 1624507140,
-            'description': 'md5:e01af24e95c74d55e8775aef86117b95',
+            'id': 'sZH1MGgomIosZgxGJ1l263MFq16oMtW1',
+            'title': 'The Late Show - 3/16/22 (Michael Buble, Rose Matafeo)',
+            'timestamp': 1647488100,
+            'description': 'md5:d0e6ec23c544b7fa8e39a8e6844d2439',
             'uploader': 'CBSI-NEW',
-            'upload_date': '20210624',
+            'upload_date': '20220317',
         },
         'params': {
             'ignore_no_formats_error': True,
@@ -130,6 +127,7 @@ def _extract_video_info(self, content_id, site='cbs', mpx_acc=2198311517):
         title = xpath_text(video_data, 'videoTitle', 'title') or xpath_text(video_data, 'videotitle', 'title')
 
         asset_types = {}
+        has_drm = False
         for item in items_data.findall('.//item'):
             asset_type = xpath_text(item, 'assetType')
             query = {
@@ -144,6 +142,8 @@ def _extract_video_info(self, content_id, site='cbs', mpx_acc=2198311517):
             if asset_type in asset_types:
                 continue
             elif any(excluded in asset_type for excluded in ('HLS_FPS', 'DASH_CENC', 'OnceURL')):
+                if 'DASH_CENC' in asset_type:
+                    has_drm = True
                 continue
             if asset_type.startswith('HLS') or 'StreamPack' in asset_type:
                 query['formats'] = 'MPEG4,M3U'
@@ -151,6 +151,9 @@ def _extract_video_info(self, content_id, site='cbs', mpx_acc=2198311517):
                 query['formats'] = 'MPEG4,FLV'
             asset_types[asset_type] = query
 
+        if not asset_types and has_drm:
+            self.report_drm(content_id)
+
         return self._extract_common_video_info(content_id, asset_types, mpx_acc, extra_info={
             'title': title,
             'series': xpath_text(video_data, 'seriesTitle'),