From 2a4f227e08538fa072b0a586883e46b8e91458ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Mon, 24 Feb 2020 23:52:05 +0100 Subject: [PATCH] warn about expired cookies --- gallery_dl/extractor/common.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/gallery_dl/extractor/common.py b/gallery_dl/extractor/common.py index fc1bfcaff13..19ee182e426 100644 --- a/gallery_dl/extractor/common.py +++ b/gallery_dl/extractor/common.py @@ -246,15 +246,22 @@ def _update_cookies_dict(self, cookiedict, domain): def _check_cookies(self, cookienames, *, domain=None): """Check if all 'cookienames' are in the session's cookiejar""" + if not self._cookiejar: + return False + if domain is None: domain = self.cookiedomain - names = set(cookienames) + now = time.time() + for cookie in self._cookiejar: - if cookie.domain == domain: - names.discard(cookie.name) - if not names: - return True + if cookie.name in names and cookie.domain == domain: + if cookie.expires and cookie.expires < now: + self.log.warning("Cookie '%s' has expired", cookie.name) + else: + names.discard(cookie.name) + if not names: + return True return False def _get_date_min_max(self, dmin=None, dmax=None):