aboutsummaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/common.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/extractor/common.py')
-rw-r--r--gallery_dl/extractor/common.py47
1 files changed, 26 insertions, 21 deletions
diff --git a/gallery_dl/extractor/common.py b/gallery_dl/extractor/common.py
index a85eedd..995505f 100644
--- a/gallery_dl/extractor/common.py
+++ b/gallery_dl/extractor/common.py
@@ -539,7 +539,7 @@ class Extractor():
for name, value in cookiedict.items():
set_cookie(name, value, domain=domain)
- def cookies_check(self, cookies_names, domain=None):
+ def cookies_check(self, cookies_names, domain=None, subdomains=False):
"""Check if all 'cookies_names' are in the session's cookiejar"""
if not self.cookies:
return False
@@ -550,26 +550,31 @@ class Extractor():
now = time.time()
for cookie in self.cookies:
- if cookie.name in names and (
- not domain or cookie.domain == domain):
-
- if cookie.expires:
- diff = int(cookie.expires - now)
-
- if diff <= 0:
- self.log.warning(
- "Cookie '%s' has expired", cookie.name)
- continue
-
- elif diff <= 86400:
- hours = diff // 3600
- self.log.warning(
- "Cookie '%s' will expire in less than %s hour%s",
- cookie.name, hours + 1, "s" if hours else "")
-
- names.discard(cookie.name)
- if not names:
- return True
+ if cookie.name not in names:
+ continue
+
+ if not domain or cookie.domain == domain:
+ pass
+ elif not subdomains or not cookie.domain.endswith(domain):
+ continue
+
+ if cookie.expires:
+ diff = int(cookie.expires - now)
+
+ if diff <= 0:
+ self.log.warning(
+ "Cookie '%s' has expired", cookie.name)
+ continue
+
+ elif diff <= 86400:
+ hours = diff // 3600
+ self.log.warning(
+ "Cookie '%s' will expire in less than %s hour%s",
+ cookie.name, hours + 1, "s" if hours else "")
+
+ names.discard(cookie.name)
+ if not names:
+ return True
return False
def _extract_jsonld(self, page):