Skip to content

Commit

Permalink
warn about expired cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Feb 24, 2020
1 parent 34887ae commit 2a4f227
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions gallery_dl/extractor/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 2a4f227

Please sign in to comment.