]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/filmon.py
[ie/mlbtv] Fix extraction (#10296)
[yt-dlp.git] / yt_dlp / extractor / filmon.py
index f775fe0baebe47eebfd1f9bcd0eea7c76623abd9..af1de7ac83be7b0fe0866b334a75fe7e0b71ac64 100644 (file)
@@ -1,16 +1,10 @@
-# coding: utf-8
-from __future__ import unicode_literals
-
 from .common import InfoExtractor
-from ..compat import (
-    compat_str,
-    compat_HTTPError,
-)
+from ..networking.exceptions import HTTPError
 from ..utils import (
+    ExtractorError,
+    int_or_none,
     qualities,
     strip_or_none,
-    int_or_none,
-    ExtractorError,
 )
 
 
@@ -40,12 +34,12 @@ def _real_extract(self, url):
 
         try:
             response = self._download_json(
-                'https://www.filmon.com/api/vod/movie?id=%s' % video_id,
+                f'https://www.filmon.com/api/vod/movie?id={video_id}',
                 video_id)['response']
         except ExtractorError as e:
-            if isinstance(e.cause, compat_HTTPError):
-                errmsg = self._parse_json(e.cause.read().decode(), video_id)['reason']
-                raise ExtractorError('%s said: %s' % (self.IE_NAME, errmsg), expected=True)
+            if isinstance(e.cause, HTTPError):
+                errmsg = self._parse_json(e.cause.response.read().decode(), video_id)['reason']
+                raise ExtractorError(f'{self.IE_NAME} said: {errmsg}', expected=True)
             raise
 
         title = response['title']
@@ -68,7 +62,6 @@ def _real_extract(self, url):
                 'quality': QUALITY(stream.get('quality')),
                 'protocol': 'm3u8_native',
             })
-        self._sort_formats(formats)
 
         thumbnails = []
         poster = response.get('poster', {})
@@ -128,12 +121,12 @@ def _real_extract(self, url):
             channel_data = self._download_json(
                 'http://www.filmon.com/api-v2/channel/' + channel_id, channel_id)['data']
         except ExtractorError as e:
-            if isinstance(e.cause, compat_HTTPError):
-                errmsg = self._parse_json(e.cause.read().decode(), channel_id)['message']
-                raise ExtractorError('%s said: %s' % (self.IE_NAME, errmsg), expected=True)
+            if isinstance(e.cause, HTTPError):
+                errmsg = self._parse_json(e.cause.response.read().decode(), channel_id)['message']
+                raise ExtractorError(f'{self.IE_NAME} said: {errmsg}', expected=True)
             raise
 
-        channel_id = compat_str(channel_data['id'])
+        channel_id = str(channel_data['id'])
         is_live = not channel_data.get('is_vod') and not channel_data.get('is_vox')
         title = channel_data['title']
 
@@ -156,13 +149,12 @@ def _real_extract(self, url):
                 'ext': 'mp4',
                 'quality': QUALITY(quality),
             })
-        self._sort_formats(formats)
 
         thumbnails = []
         for name, width, height in self._THUMBNAIL_RES:
             thumbnails.append({
                 'id': name,
-                'url': 'http://static.filmon.com/assets/channels/%s/%s.png' % (channel_id, name),
+                'url': f'http://static.filmon.com/assets/channels/{channel_id}/{name}.png',
                 'width': width,
                 'height': height,
             })
@@ -170,7 +162,7 @@ def _real_extract(self, url):
         return {
             'id': channel_id,
             'display_id': channel_data.get('alias'),
-            'title': self._live_title(title) if is_live else title,
+            'title': title,
             'description': channel_data.get('description'),
             'thumbnails': thumbnails,
             'formats': formats,