]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/brightcove.py
[extractor] Deprecate `_sort_formats`
[yt-dlp.git] / yt_dlp / extractor / brightcove.py
index dcd332b435de6934f4d0155004bf8ed313719359..35e1aa9c9dac6f95f0d2c47b4e8101b54fdf4d10 100644 (file)
@@ -1,9 +1,7 @@
-# coding: utf-8
-from __future__ import unicode_literals
-
 import base64
 import re
 import struct
+import xml.etree.ElementTree
 
 from .adobepass import AdobePassIE
 from .common import InfoExtractor
@@ -12,7 +10,6 @@
     compat_HTTPError,
     compat_parse_qs,
     compat_urlparse,
-    compat_xml_parse_error,
 )
 from ..utils import (
     clean_html,
@@ -166,7 +163,7 @@ def _build_brightcove_url(cls, object_str):
 
         try:
             object_doc = compat_etree_fromstring(object_str.encode('utf-8'))
-        except compat_xml_parse_error:
+        except xml.etree.ElementTree.ParseError:
             return
 
         fv_el = find_xpath_attr(object_doc, './param', 'name', 'flashVars')
@@ -405,11 +402,11 @@ class BrightcoveNewIE(AdobePassIE):
 
     @staticmethod
     def _extract_url(ie, webpage):
-        urls = BrightcoveNewIE._extract_urls(ie, webpage)
+        urls = BrightcoveNewIE._extract_brightcove_urls(ie, webpage)
         return urls[0] if urls else None
 
     @staticmethod
-    def _extract_urls(ie, webpage):
+    def _extract_brightcove_urls(ie, webpage):
         # Reference:
         # 1. http://docs.brightcove.com/en/video-cloud/brightcove-player/guides/publish-video.html#setvideoiniframe
         # 2. http://docs.brightcove.com/en/video-cloud/brightcove-player/guides/publish-video.html#tag
@@ -549,8 +546,6 @@ def build_format_id(kind):
                 self.raise_no_formats(
                     error.get('message') or error.get('error_subcode') or error['error_code'], expected=True)
 
-        self._sort_formats(formats)
-
         for f in formats:
             f.setdefault('http_headers', {}).update(headers)
 
@@ -603,9 +598,9 @@ def _real_extract(self, url):
         account_id, player_id, embed, content_type, video_id = self._match_valid_url(url).groups()
 
         policy_key_id = '%s_%s' % (account_id, player_id)
-        policy_key = self._downloader.cache.load('brightcove', policy_key_id)
+        policy_key = self.cache.load('brightcove', policy_key_id)
         policy_key_extracted = False
-        store_pk = lambda x: self._downloader.cache.store('brightcove', policy_key_id, x)
+        store_pk = lambda x: self.cache.store('brightcove', policy_key_id, x)
 
         def extract_policy_key():
             base_url = 'http://players.brightcove.net/%s/%s_%s/' % (account_id, player_id, embed)