1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-10-31 14:45:14 +00:00

[ie] Do not test truth value of xml.etree.ElementTree.Element (#8582)

Testing the truthiness of an `xml.etree.ElementTree.Element` instance is deprecated in py3.12

Authored by: bashonly
This commit is contained in:
bashonly
2023-11-14 14:28:18 -06:00
committed by GitHub
parent 87264d4fda
commit d4f14a72dc
5 changed files with 21 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
import base64
import json
import re
import xml.etree.ElementTree
from .common import InfoExtractor
from .theplatform import ThePlatformIE, default_ns
@@ -803,8 +804,10 @@ class NBCStationsIE(InfoExtractor):
smil = self._download_xml(
f'https://link.theplatform.com/s/{pdk_acct}/{player_id}', video_id,
note='Downloading SMIL data', query=query, fatal=is_live)
subtitles = self._parse_smil_subtitles(smil, default_ns) if smil else {}
for video in smil.findall(self._xpath_ns('.//video', default_ns)) if smil else []:
if not isinstance(smil, xml.etree.ElementTree.Element):
smil = None
subtitles = self._parse_smil_subtitles(smil, default_ns) if smil is not None else {}
for video in smil.findall(self._xpath_ns('.//video', default_ns)) if smil is not None else []:
info['duration'] = float_or_none(remove_end(video.get('dur'), 'ms'), 1000)
video_src_url = video.get('src')
ext = mimetype2ext(video.get('type'), default=determine_ext(video_src_url))