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:
|
def login(self, cookies=None) -> bool:
|
||||||
"""
|
"""
|
||||||
Logs this instance into FurAffinity.
|
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.
|
:param cookies: Cookies to use for this session.
|
||||||
:return: Whether the login attempt was successful.
|
:return: Whether the login attempt was successful.
|
||||||
"""
|
"""
|
||||||
@ -465,7 +465,9 @@ class FAAPI:
|
|||||||
# No need to do anything if we're already logged in
|
# No need to do anything if we're already logged in
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if not cookies:
|
if cookies:
|
||||||
|
self._cookies = cookies
|
||||||
|
elif not self._cookies:
|
||||||
# Try sign in to FA
|
# Try sign in to FA
|
||||||
driver = webdriver.Chrome()
|
driver = webdriver.Chrome()
|
||||||
driver.get(FA_BASE_URL + '/login')
|
driver.get(FA_BASE_URL + '/login')
|
||||||
@ -477,8 +479,6 @@ class FAAPI:
|
|||||||
# Extract the cookies and stop the driver
|
# Extract the cookies and stop the driver
|
||||||
self._cookies = driver.get_cookies()
|
self._cookies = driver.get_cookies()
|
||||||
driver.close()
|
driver.close()
|
||||||
else:
|
|
||||||
self._cookies = cookies
|
|
||||||
|
|
||||||
# Set up the Requests session with the cookies we just got
|
# Set up the Requests session with the cookies we just got
|
||||||
[self._req.cookies.set(cookie['name'], cookie['value']) for cookie in self._cookies]
|
[self._req.cookies.set(cookie['name'], cookie['value']) for cookie in self._cookies]
|
||||||
|
|||||||
2
setup.py
2
setup.py
@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='FAAPI',
|
name='FAAPI',
|
||||||
version='0.4.2',
|
version='0.5.0',
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
url='https://tem.party/gitea/tom/FAAPI',
|
url='https://tem.party/gitea/tom/FAAPI',
|
||||||
license='WTFPL',
|
license='WTFPL',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user