Use compat_etree_Element

This commit is contained in:
Sergey M․ 2019-03-06 01:21:57 +07:00
parent 399f76870d
commit ee0ba927aa
No known key found for this signature in database
GPG key ID: 2C393E0F18A9236D
3 changed files with 11 additions and 11 deletions

View file

@ -3,7 +3,6 @@ from __future__ import unicode_literals
import itertools import itertools
import re import re
import xml
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import (
@ -23,6 +22,7 @@ from ..utils import (
urljoin, urljoin,
) )
from ..compat import ( from ..compat import (
compat_etree_Element,
compat_HTTPError, compat_HTTPError,
compat_urlparse, compat_urlparse,
) )
@ -317,7 +317,7 @@ class BBCCoUkIE(InfoExtractor):
continue continue
captions = self._download_xml( captions = self._download_xml(
cc_url, programme_id, 'Downloading captions', fatal=False) cc_url, programme_id, 'Downloading captions', fatal=False)
if not isinstance(captions, xml.etree.ElementTree.Element): if not isinstance(captions, compat_etree_Element):
continue continue
lang = captions.get('{http://www.w3.org/XML/1998/namespace}lang', 'en') lang = captions.get('{http://www.w3.org/XML/1998/namespace}lang', 'en')
subtitles[lang] = [ subtitles[lang] = [

View file

@ -13,11 +13,11 @@ import socket
import sys import sys
import time import time
import math import math
import xml
from ..compat import ( from ..compat import (
compat_cookiejar, compat_cookiejar,
compat_cookies, compat_cookies,
compat_etree_Element,
compat_etree_fromstring, compat_etree_fromstring,
compat_getpass, compat_getpass,
compat_integer_types, compat_integer_types,
@ -802,7 +802,7 @@ class InfoExtractor(object):
fatal=True, encoding=None, data=None, headers={}, query={}, fatal=True, encoding=None, data=None, headers={}, query={},
expected_status=None): expected_status=None):
""" """
Return a tuple (xml as an xml.etree.ElementTree.Element, URL handle). Return a tuple (xml as an compat_etree_Element, URL handle).
See _download_webpage docstring for arguments specification. See _download_webpage docstring for arguments specification.
""" """
@ -823,7 +823,7 @@ class InfoExtractor(object):
transform_source=None, fatal=True, encoding=None, transform_source=None, fatal=True, encoding=None,
data=None, headers={}, query={}, expected_status=None): data=None, headers={}, query={}, expected_status=None):
""" """
Return the xml as an xml.etree.ElementTree.Element. Return the xml as an compat_etree_Element.
See _download_webpage docstring for arguments specification. See _download_webpage docstring for arguments specification.
""" """
@ -1468,7 +1468,7 @@ class InfoExtractor(object):
def _parse_f4m_formats(self, manifest, manifest_url, video_id, preference=None, f4m_id=None, def _parse_f4m_formats(self, manifest, manifest_url, video_id, preference=None, f4m_id=None,
transform_source=lambda s: fix_xml_ampersands(s).strip(), transform_source=lambda s: fix_xml_ampersands(s).strip(),
fatal=True, m3u8_id=None): fatal=True, m3u8_id=None):
if not isinstance(manifest, xml.etree.ElementTree.Element) and not fatal: if not isinstance(manifest, compat_etree_Element) and not fatal:
return [] return []
# currently youtube-dl cannot decode the playerVerificationChallenge as Akamai uses Adobe Alchemy # currently youtube-dl cannot decode the playerVerificationChallenge as Akamai uses Adobe Alchemy

View file

@ -3,7 +3,6 @@ from __future__ import unicode_literals
import re import re
import json import json
import xml.etree.ElementTree as etree
import zlib import zlib
from hashlib import sha1 from hashlib import sha1
@ -12,6 +11,7 @@ from .common import InfoExtractor
from .vrv import VRVIE from .vrv import VRVIE
from ..compat import ( from ..compat import (
compat_b64decode, compat_b64decode,
compat_etree_Element,
compat_etree_fromstring, compat_etree_fromstring,
compat_urllib_parse_urlencode, compat_urllib_parse_urlencode,
compat_urllib_request, compat_urllib_request,
@ -390,7 +390,7 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
'Downloading subtitles for ' + sub_name, data={ 'Downloading subtitles for ' + sub_name, data={
'subtitle_script_id': sub_id, 'subtitle_script_id': sub_id,
}) })
if not isinstance(sub_doc, etree.Element): if not isinstance(sub_doc, compat_etree_Element):
continue continue
sid = sub_doc.get('id') sid = sub_doc.get('id')
iv = xpath_text(sub_doc, 'iv', 'subtitle iv') iv = xpath_text(sub_doc, 'iv', 'subtitle iv')
@ -507,7 +507,7 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
'video_quality': stream_quality, 'video_quality': stream_quality,
'current_page': url, 'current_page': url,
}) })
if isinstance(streamdata, etree.Element): if isinstance(streamdata, compat_etree_Element):
stream_info = streamdata.find('./{default}preload/stream_info') stream_info = streamdata.find('./{default}preload/stream_info')
if stream_info is not None: if stream_info is not None:
stream_infos.append(stream_info) stream_infos.append(stream_info)
@ -518,7 +518,7 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
'video_format': stream_format, 'video_format': stream_format,
'video_encode_quality': stream_quality, 'video_encode_quality': stream_quality,
}) })
if isinstance(stream_info, etree.Element): if isinstance(stream_info, compat_etree_Element):
stream_infos.append(stream_info) stream_infos.append(stream_info)
for stream_info in stream_infos: for stream_info in stream_infos:
video_encode_id = xpath_text(stream_info, './video_encode_id') video_encode_id = xpath_text(stream_info, './video_encode_id')
@ -593,7 +593,7 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
season = episode = episode_number = duration = thumbnail = None season = episode = episode_number = duration = thumbnail = None
if isinstance(metadata, etree.Element): if isinstance(metadata, compat_etree_Element):
season = xpath_text(metadata, 'series_title') season = xpath_text(metadata, 'series_title')
episode = xpath_text(metadata, 'episode_title') episode = xpath_text(metadata, 'episode_title')
episode_number = int_or_none(xpath_text(metadata, 'episode_number')) episode_number = int_or_none(xpath_text(metadata, 'episode_number'))