diff --git a/src/streamlink/plugins/nicolive.py b/src/streamlink/plugins/nicolive.py index 38d49799711..c13416cc514 100644 --- a/src/streamlink/plugins/nicolive.py +++ b/src/streamlink/plugins/nicolive.py @@ -260,10 +260,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: @@ -283,7 +289,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(f"Cookies: {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())")