mirror of https://github.com/streamlink/streamlink
plugins: replace XPath f-strings with variables
This commit is contained in:
parent
1ea5663971
commit
156b6602f4
|
@ -44,7 +44,7 @@ class DeutscheWelle(Plugin):
|
|||
# find the video element of the selected channel ID first
|
||||
# node-sets are always ordered by the document order, so these queries can't be merged into one
|
||||
validate.all(
|
||||
validate.xml_xpath(f".//video[../@data-channel-id='{channel}'][1]"),
|
||||
validate.xml_xpath(".//video[../@data-channel-id=$channel][1]", channel=channel),
|
||||
# validate.xml_element() can't be used here, because it discards parent nodes of the cloned return value
|
||||
lambda res: res is not None,
|
||||
validate.get(0),
|
||||
|
|
|
@ -146,7 +146,7 @@ class Experience:
|
|||
def login_csrf(self):
|
||||
return self.session.http.get(self.login_url, schema=validate.Schema(
|
||||
validate.parse_html(),
|
||||
validate.xml_xpath_string(f".//input[@name='{self.CSRF_NAME}'][1]/@value")
|
||||
validate.xml_xpath_string(".//input[@name=$name][1]/@value", name=self.CSRF_NAME)
|
||||
))
|
||||
|
||||
def login(self, email, password):
|
||||
|
|
|
@ -35,7 +35,8 @@ class MDStrm(Plugin):
|
|||
pattern = fr"{search_string}\s*=\s*'([^']+)';"
|
||||
_schema = validate.Schema(
|
||||
validate.xml_xpath_string(
|
||||
f".//script[@type='text/javascript'][contains(text(),'{search_string}')]/text()",
|
||||
".//script[@type='text/javascript'][contains(text(),$search_string)]/text()",
|
||||
search_string=search_string,
|
||||
),
|
||||
validate.none_or_all(
|
||||
re.compile(pattern),
|
||||
|
|
|
@ -22,15 +22,15 @@ class UseeTV(Plugin):
|
|||
|
||||
for needle, errormsg in (
|
||||
(
|
||||
"This service is not available in your Country",
|
||||
"\"This service is not available in your Country\"",
|
||||
"The content is not available in your region",
|
||||
),
|
||||
(
|
||||
"Silahkan login Menggunakan akun MyIndihome dan berlangganan minipack",
|
||||
"\"Silahkan login Menggunakan akun MyIndihome dan berlangganan minipack\"",
|
||||
"The content is not available without a subscription",
|
||||
),
|
||||
):
|
||||
if validate.Schema(validate.xml_xpath(f""".//script[contains(text(), '"{needle}"')]""")).validate(root):
|
||||
if validate.Schema(validate.xml_xpath(".//script[contains(text(),$needle)]", needle=needle)).validate(root):
|
||||
log.error(errormsg)
|
||||
return
|
||||
|
||||
|
|
Loading…
Reference in New Issue