[newgrounds] only login if necessary (#2715)

This commit is contained in:
Mike Fährmann
2022-06-29 11:46:07 +02:00
parent 86a7dad081
commit 37453a9528
2 changed files with 9 additions and 4 deletions

View File

@@ -72,6 +72,8 @@ class NewgroundsExtractor(Extractor):
"""Return general metadata"""
def login(self):
if self._check_cookies(self.cookienames):
return
username, password = self._get_auth_info()
if username:
self._update_cookies(self._login_impl(username, password))
@@ -81,10 +83,13 @@ class NewgroundsExtractor(Extractor):
self.log.info("Logging in as %s", username)
url = self.root + "/passport/"
page = self.request(url).text
headers = {"Origin": self.root, "Referer": url}
response = self.request(url)
if response.history and response.url.endswith("/social"):
return self.session.cookies
url = text.urljoin(self.root, text.extract(page, 'action="', '"')[0])
headers = {"Origin": self.root, "Referer": url}
url = text.urljoin(self.root, text.extract(
response.text, 'action="', '"')[0])
data = {
"username": username,
"password": password,

View File

@@ -6,4 +6,4 @@
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
__version__ = "1.22.3"
__version__ = "1.22.4-dev"