consistent cookie-related names

- rename every cookie variable or method to 'cookies_*'
- simplify '.session.cookies' to just '.cookies'
- more consistent 'login()' structure
This commit is contained in:
Mike Fährmann
2023-07-21 22:38:39 +02:00
parent ceebacc9e1
commit d97b8c2fba
50 changed files with 278 additions and 261 deletions

View File

@@ -27,7 +27,7 @@ class _8chanExtractor(Extractor):
Extractor.__init__(self, match)
@memcache()
def _prepare_cookies(self):
def cookies_prepare(self):
# fetch captcha cookies
# (necessary to download without getting interrupted)
now = datetime.utcnow()
@@ -39,14 +39,14 @@ class _8chanExtractor(Extractor):
# - remove 'expires' timestamp
# - move 'captchaexpiration' value forward by 1 month)
domain = self.root.rpartition("/")[2]
for cookie in self.session.cookies:
for cookie in self.cookies:
if cookie.domain.endswith(domain):
cookie.expires = None
if cookie.name == "captchaexpiration":
cookie.value = (now + timedelta(30, 300)).strftime(
"%a, %d %b %Y %H:%M:%S GMT")
return self.session.cookies
return self.cookies
class _8chanThreadExtractor(_8chanExtractor):
@@ -113,7 +113,7 @@ class _8chanThreadExtractor(_8chanExtractor):
thread["_http_headers"] = {"Referer": url + "html"}
try:
self.session.cookies = self._prepare_cookies()
self.cookies = self.cookies_prepare()
except Exception as exc:
self.log.debug("Failed to fetch captcha cookies: %s: %s",
exc.__class__.__name__, exc, exc_info=True)