]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/tvigle.py
[ie/matchtv] Fix extractor (#10190)
[yt-dlp.git] / yt_dlp / extractor / tvigle.py
index aa25ba0dc1a2d8f4950ef7a629c8fd5c397b5069..6b87ecac745b410cf1c750685541eb87404534f4 100644 (file)
@@ -1,7 +1,3 @@
-# coding: utf-8
-from __future__ import unicode_literals
-
-
 from .common import InfoExtractor
 from ..utils import (
     ExtractorError,
@@ -17,6 +13,7 @@ class TvigleIE(InfoExtractor):
     IE_NAME = 'tvigle'
     IE_DESC = 'Интернет-телевидение Tvigle.ru'
     _VALID_URL = r'https?://(?:www\.)?(?:tvigle\.ru/(?:[^/]+/)+(?P<display_id>[^/]+)/$|cloud\.tvigle\.ru/video/(?P<id>\d+))'
+    _EMBED_REGEX = [r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//cloud\.tvigle\.ru/video/.+?)\1']
 
     _GEO_BYPASS = False
     _GEO_COUNTRIES = ['RU']
@@ -49,7 +46,7 @@ class TvigleIE(InfoExtractor):
         }, {
             'url': 'https://cloud.tvigle.ru/video/5267604/',
             'only_matching': True,
-        }
+        },
     ]
 
     def _real_extract(self, url):
@@ -66,7 +63,7 @@ def _real_extract(self, url):
                 webpage, 'video id')
 
         video_data = self._download_json(
-            'http://cloud.tvigle.ru/api/play/video/%s/' % video_id, display_id)
+            f'http://cloud.tvigle.ru/api/play/video/{video_id}/', display_id)
 
         item = video_data['playlist']['items'][0]
 
@@ -79,7 +76,7 @@ def _real_extract(self, url):
                     msg=error_message, countries=self._GEO_COUNTRIES)
             else:
                 raise ExtractorError(
-                    '%s returned error: %s' % (self.IE_NAME, error_message),
+                    f'{self.IE_NAME} returned error: {error_message}',
                     expected=True)
 
         title = item['title']
@@ -118,12 +115,11 @@ def _real_extract(self, url):
                         item, lambda x: x['video_files_size'][vcodec][format_id]))
                     formats.append({
                         'url': video_url,
-                        'format_id': '%s-%s' % (vcodec, format_id),
+                        'format_id': f'{vcodec}-{format_id}',
                         'vcodec': vcodec,
                         'height': int_or_none(height),
                         'filesize': filesize,
                     })
-        self._sort_formats(formats)
 
         return {
             'id': video_id,