]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/stv.py
[cleanup] Add more ruff rules (#10149)
[yt-dlp.git] / yt_dlp / extractor / stv.py
index 618dc4329a971984689700b41357c0f4ee17d29d..c489e4237cd7347f23cdbe96307267e5bf0ea1c2 100644 (file)
@@ -1,6 +1,5 @@
 from .common import InfoExtractor
 from ..utils import (
-    compat_str,
     float_or_none,
     int_or_none,
     smuggle_url,
@@ -21,7 +20,7 @@ class STVPlayerIE(InfoExtractor):
             'ext': 'mp4',
             'upload_date': '20170301',
             'title': '60 seconds on set with Laura Norton',
-            'description': "How many questions can Laura - a.k.a Kerry Wyatt - answer in 60 seconds? Let\'s find out!",
+            'description': "How many questions can Laura - a.k.a Kerry Wyatt - answer in 60 seconds? Let's find out!",
             'timestamp': 1488388054,
             'uploader_id': '1486976045',
         },
@@ -41,19 +40,19 @@ def _real_extract(self, url):
         ptype, video_id = self._match_valid_url(url).groups()
 
         webpage = self._download_webpage(url, video_id, fatal=False) or ''
-        props = self._search_nextjs_data(webpage, video_id, default='{}').get('props') or {}
+        props = self._search_nextjs_data(webpage, video_id, default={}).get('props') or {}
         player_api_cache = try_get(
             props, lambda x: x['initialReduxState']['playerApiCache']) or {}
 
         api_path, resp = None, {}
         for k, v in player_api_cache.items():
-            if k.startswith('/episodes/') or k.startswith('/shortform/'):
+            if k.startswith(('/episodes/', '/shortform/')):
                 api_path, resp = k, v
                 break
         else:
             episode_id = str_or_none(try_get(
                 props, lambda x: x['pageProps']['episodeId']))
-            api_path = '/%s/%s' % (self._PTYPE_MAP[ptype], episode_id or video_id)
+            api_path = f'/{self._PTYPE_MAP[ptype]}/{episode_id or video_id}'
 
         result = resp.get('results')
         if not result:
@@ -62,7 +61,7 @@ def _real_extract(self, url):
             result = resp['results']
 
         video = result['video']
-        video_id = compat_str(video['id'])
+        video_id = str(video['id'])
 
         subtitles = {}
         _subtitles = result.get('_subtitles') or {}
@@ -73,6 +72,8 @@ def _real_extract(self, url):
             })
 
         programme = result.get('programme') or {}
+        if programme.get('drmEnabled'):
+            self.report_drm(video_id)
 
         return {
             '_type': 'url_transparent',