From a4dd8b3dab62c1b77723ca3add8e1e8a1cde40f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Fri, 13 Dec 2019 15:51:20 +0100 Subject: [PATCH] improve _check_cookies() Only loop over all cookies once instead of calling cookiejar._find() for each cookie name. --- gallery_dl/extractor/common.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gallery_dl/extractor/common.py b/gallery_dl/extractor/common.py index a36a1d81..95a81112 100644 --- a/gallery_dl/extractor/common.py +++ b/gallery_dl/extractor/common.py @@ -229,12 +229,14 @@ class Extractor(): """Check if all 'cookienames' are in the session's cookiejar""" if domain is None: domain = self.cookiedomain - try: - for name in cookienames: - self._cookiejar._find(name, domain) - except KeyError: - return False - return True + + names = set(cookienames) + for cookie in self._cookiejar: + if cookie.domain == domain: + names.discard(cookie.name) + if not names: + return True + return False def _get_date_min_max(self, dmin=None, dmax=None): """Retrieve and parse 'date-min' and 'date-max' config values"""