Use existing cookies by default
They can still be overridden by supplying custom cookies though
This commit is contained in:
parent
b3a5b4acdb
commit
676a619775
@ -457,7 +457,7 @@ class FAAPI:
|
||||
def login(self, cookies=None) -> bool:
|
||||
"""
|
||||
Logs this instance into FurAffinity.
|
||||
Beware that a Chrome instance is launched to bypass Cloudflare and log in. Specify valid cookies to bypass this.
|
||||
Beware that a Chrome instance may be launched to bypass Cloudflare and log in. Specify cookies to bypass this.
|
||||
:param cookies: Cookies to use for this session.
|
||||
:return: Whether the login attempt was successful.
|
||||
"""
|
||||
@ -465,7 +465,9 @@ class FAAPI:
|
||||
# No need to do anything if we're already logged in
|
||||
return True
|
||||
|
||||
if not cookies:
|
||||
if cookies:
|
||||
self._cookies = cookies
|
||||
elif not self._cookies:
|
||||
# Try sign in to FA
|
||||
driver = webdriver.Chrome()
|
||||
driver.get(FA_BASE_URL + '/login')
|
||||
@ -477,8 +479,6 @@ class FAAPI:
|
||||
# Extract the cookies and stop the driver
|
||||
self._cookies = driver.get_cookies()
|
||||
driver.close()
|
||||
else:
|
||||
self._cookies = cookies
|
||||
|
||||
# Set up the Requests session with the cookies we just got
|
||||
[self._req.cookies.set(cookie['name'], cookie['value']) for cookie in self._cookies]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user