From ed317bfcf111354477b06f33e62276e35b9f2bca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sat, 12 Feb 2022 01:57:06 +0100 Subject: [PATCH] warn about cookies expiring in less than 24 hours requires an expiration timestamp, so this only works with cookies from a cookies.txt file --- gallery_dl/extractor/common.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gallery_dl/extractor/common.py b/gallery_dl/extractor/common.py index fbdf0f55..5a2d3a39 100644 --- a/gallery_dl/extractor/common.py +++ b/gallery_dl/extractor/common.py @@ -371,8 +371,16 @@ class Extractor(): for cookie in self._cookiejar: if cookie.name in names and ( not domain or cookie.domain == domain): - if cookie.expires and cookie.expires < now: - self.log.warning("Cookie '%s' has expired", cookie.name) + if cookie.expires: + diff = int(cookie.expires - now) + if diff <= 0: + self.log.warning( + "Cookie '%s' has expired", cookie.name) + 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 "") else: names.discard(cookie.name) if not names: