]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/rts.py
[ie/matchtv] Fix extractor (#10190)
[yt-dlp.git] / yt_dlp / extractor / rts.py
index e5ba1a26bd72f03af3981b68f5c3df9275483bbb..dc1e2d3b449717f56c23fc9c92019f05d26233f0 100644 (file)
@@ -1,7 +1,6 @@
 import re
 
 from .srgssr import SRGSSRIE
-from ..compat import compat_str
 from ..utils import (
     determine_ext,
     int_or_none,
@@ -12,7 +11,8 @@
 )
 
 
-class RTSIE(SRGSSRIE):
+class RTSIE(SRGSSRIE):  # XXX: Do not subclass from concrete IE
+    _WORKING = False
     IE_DESC = 'RTS.ch'
     _VALID_URL = r'rts:(?P<rts_id>\d+)|https?://(?:.+?\.)?rts\.ch/(?:[^/]+/){2,}(?P<id>[0-9]+)-(?P<display_id>.+?)\.html'
 
@@ -109,7 +109,7 @@ class RTSIE(SRGSSRIE):
         {
             'url': 'http://pages.rts.ch/emissions/passe-moi-les-jumelles/5624065-entre-ciel-et-mer.html',
             'only_matching': True,
-        }
+        },
     ]
 
     def _real_extract(self, url):
@@ -119,7 +119,7 @@ def _real_extract(self, url):
 
         def download_json(internal_id):
             return self._download_json(
-                'http://www.rts.ch/a/%s.html?f=json/article' % internal_id,
+                f'http://www.rts.ch/a/{internal_id}.html?f=json/article',
                 display_id)
 
         all_info = download_json(media_id)
@@ -136,8 +136,8 @@ def download_json(internal_id):
 
             if not entries:
                 page, urlh = self._download_webpage_handle(url, display_id)
-                if re.match(self._VALID_URL, urlh.geturl()).group('id') != media_id:
-                    return self.url_result(urlh.geturl(), 'RTS')
+                if re.match(self._VALID_URL, urlh.url).group('id') != media_id:
+                    return self.url_result(urlh.url, 'RTS')
 
                 # article with videos on rhs
                 videos = re.findall(
@@ -148,7 +148,7 @@ def download_json(internal_id):
                         r'(?s)<iframe[^>]+class="srg-player"[^>]+src="[^"]+urn:([^"]+)"',
                         page)
                 if videos:
-                    entries = [self.url_result('srgssr:%s' % video_urn, 'SRGSSR') for video_urn in videos]
+                    entries = [self.url_result(f'srgssr:{video_urn}', 'SRGSSR') for video_urn in videos]
 
             if entries:
                 return self.playlist_result(entries, media_id, all_info.get('title'))
@@ -195,7 +195,7 @@ def extract_bitrate(url):
                     'tbr': extract_bitrate(format_url),
                 })
 
-        download_base = 'http://rtsww%s-d.rts.ch/' % ('-a' if media_type == 'audio' else '')
+        download_base = 'http://rtsww{}-d.rts.ch/'.format('-a' if media_type == 'audio' else '')
         for media in info.get('media', []):
             media_url = media.get('url')
             if not media_url or re.match(r'https?://', media_url):
@@ -212,10 +212,9 @@ def extract_bitrate(url):
             })
 
         self._check_formats(formats, media_id)
-        self._sort_formats(formats)
 
         duration = info.get('duration') or info.get('cutout') or info.get('cutduration')
-        if isinstance(duration, compat_str):
+        if isinstance(duration, str):
             duration = parse_duration(duration)
 
         return {