]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/ninecninemedia.py
[extractor] Deprecate `_sort_formats`
[yt-dlp.git] / yt_dlp / extractor / ninecninemedia.py
index d1281167a7704fa21ec07164a02fca9897fc4200..31df42f4f6ca52a7c53f2087cac079cfdd5b3a89 100644 (file)
@@ -1,10 +1,5 @@
-# coding: utf-8
-from __future__ import unicode_literals
-
-
 from .common import InfoExtractor
 from ..utils import (
-    ExtractorError,
     float_or_none,
     int_or_none,
     parse_iso8601,
@@ -35,7 +30,7 @@ def _real_extract(self, url):
 
         if (not self.get_param('allow_unplayable_formats')
                 and try_get(content_package, lambda x: x['Constraints']['Security']['Type'])):
-            raise ExtractorError('This video is DRM protected.', expected=True)
+            self.report_drm(content_id)
 
         manifest_base_url = content_package_url + 'manifest.'
         formats = []
@@ -48,7 +43,6 @@ def _real_extract(self, url):
         formats.extend(self._extract_mpd_formats(
             manifest_base_url + 'mpd', content_id,
             mpd_id='dash', fatal=False))
-        self._sort_formats(formats)
 
         thumbnails = []
         for image in (content.get('Images') or []):
@@ -100,3 +94,37 @@ def _real_extract(self, url):
             }
 
         return info
+
+
+class CPTwentyFourIE(InfoExtractor):
+    IE_NAME = 'cp24'
+    _GEO_COUNTRIES = ['CA']
+    _VALID_URL = r'https?://(?:www\.)?cp24\.com/news/(?P<id>[^?#]+)'
+
+    _TESTS = [{
+        'url': 'https://www.cp24.com/news/video-shows-atm-being-ripped-out-of-business-by-pickup-truck-driver-in-mississauga-1.5676877',
+        'info_dict': {
+            'id': '2328005',
+            'ext': 'mp4',
+            'title': 'WATCH: Truck rips ATM from Mississauga business',
+            'description': 'md5:cf7498480885f080a754389a2b2f7073',
+            'timestamp': 1637618377,
+            'episode_number': None,
+            'season': 'Season 0',
+            'season_number': 0,
+            'season_id': 57974,
+            'series': 'CTV News Toronto',
+            'duration': 26.86,
+            'thumbnail': 'http://images2.9c9media.com/image_asset/2014_11_5_2eb609a0-475b-0132-fbd6-34b52f6f1279_jpg_2000x1125.jpg',
+            'upload_date': '20211122',
+        },
+        'params': {'skip_download': True, 'format': 'bv'}
+    }]
+
+    def _real_extract(self, url):
+        display_id = self._match_id(url)
+        webpage = self._download_webpage(url, display_id)
+        id, destination = self._search_regex(
+            r'getAuthStates\("(?P<id>[^"]+)",\s?"(?P<destination>[^"]+)"\);',
+            webpage, 'video id and destination', group=('id', 'destination'))
+        return self.url_result(f'9c9media:{destination}:{id}', ie=NineCNineMediaIE.ie_key(), video_id=id)