Skip to content

Commit

Permalink
[PATCH] plugins.nicolive: fix email logins (streamlink#4553)
Browse files Browse the repository at this point in the history
  • Loading branch information
Billy2011 committed Jun 7, 2022
1 parent 990d45b commit 09a7758
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/streamlink/plugins/nicolive.py
Expand Up @@ -251,10 +251,16 @@ def niconico_web_login(self):
self.LOGIN_URL,
data={"mail_tel": email, "password": password},
params=self.LOGIN_URL_PARAMS,
schema=validate.Schema(validate.parse_html()))
schema=validate.Schema(validate.parse_html()),
)

if self.session.http.cookies.get("user_session"):
log.info("Logged in.")
self.save_cookies()
return

input_with_value = {}
for elem in root.xpath(".//input"):
for elem in root.xpath(".//form[@action]//input"):
if elem.attrib.get("value"):
input_with_value[elem.attrib.get("name")] = elem.attrib.get("value")
else:
Expand All @@ -274,7 +280,8 @@ def niconico_web_login(self):
root = self.session.http.post(
urljoin("https://account.nicovideo.jp", root.xpath("string(.//form[@action]/@action)")),
data=input_with_value,
schema=validate.Schema(validate.parse_html()))
schema=validate.Schema(validate.parse_html()),
)
log.debug("Cookies: {0}".format(self.session.http.cookies.get_dict()))
if self.session.http.cookies.get("user_session") is None:
error = root.xpath("string(//div[@class='formError']/div/text())")
Expand Down

0 comments on commit 09a7758

Please sign in to comment.