]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/atresplayer.py
[ie/matchtv] Fix extractor (#10190)
[yt-dlp.git] / yt_dlp / extractor / atresplayer.py
index 8143eb4d755bc22eacbdf097e57e8440f0d72942..7c8139714f11da2904990576ea8891762832fef1 100644 (file)
@@ -1,9 +1,5 @@
-# coding: utf-8
-from __future__ import unicode_literals
-
-
 from .common import InfoExtractor
-from ..compat import compat_HTTPError
+from ..networking.exceptions import HTTPError
 from ..utils import (
     ExtractorError,
     int_or_none,
@@ -24,10 +20,7 @@ class AtresPlayerIE(InfoExtractor):
                 'description': 'md5:7634cdcb4d50d5381bedf93efb537fbc',
                 'duration': 3413,
             },
-            'params': {
-                'format': 'bestvideo',
-            },
-            'skip': 'This video is only available for registered users'
+            'skip': 'This video is only available for registered users',
         },
         {
             'url': 'https://www.atresplayer.com/lasexta/programas/el-club-de-la-comedia/temporada-4/capitulo-10-especial-solidario-nochebuena_5ad08edf986b2855ed47adc4/',
@@ -40,22 +33,15 @@ class AtresPlayerIE(InfoExtractor):
     ]
     _API_BASE = 'https://api.atresplayer.com/'
 
-    def _real_initialize(self):
-        self._login()
-
     def _handle_error(self, e, code):
-        if isinstance(e.cause, compat_HTTPError) and e.cause.code == code:
-            error = self._parse_json(e.cause.read(), None)
+        if isinstance(e.cause, HTTPError) and e.cause.status == code:
+            error = self._parse_json(e.cause.response.read(), None)
             if error.get('error') == 'required_registered':
                 self.raise_login_required()
             raise ExtractorError(error['error_description'], expected=True)
         raise
 
-    def _login(self):
-        username, password = self._get_login_info()
-        if username is None:
-            return
-
+    def _perform_login(self, username, password):
         self._request_webpage(
             self._API_BASE + 'login', None, 'Downloading login page')
 
@@ -63,7 +49,7 @@ def _login(self):
             target_url = self._download_json(
                 'https://account.atresmedia.com/api/login', None,
                 'Logging in', headers={
-                    'Content-Type': 'application/x-www-form-urlencoded'
+                    'Content-Type': 'application/x-www-form-urlencoded',
                 }, data=urlencode_postdata({
                     'username': username,
                     'password': password,
@@ -98,7 +84,6 @@ def _real_extract(self, url):
             elif src_type == 'application/dash+xml':
                 formats, subtitles = self._extract_mpd_formats(
                     src, video_id, mpd_id='dash', fatal=False)
-        self._sort_formats(formats)
 
         heartbeat = episode.get('heartbeat') or {}
         omniture = episode.get('omniture') or {}