diff options
Diffstat (limited to 'gallery_dl/extractor/common.py')
| -rw-r--r-- | gallery_dl/extractor/common.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/gallery_dl/extractor/common.py b/gallery_dl/extractor/common.py index a1a4890..380bcc7 100644 --- a/gallery_dl/extractor/common.py +++ b/gallery_dl/extractor/common.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2014-2019 Mike Fährmann +# Copyright 2014-2020 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as @@ -122,6 +122,24 @@ class Extractor(): raise exception.HttpError(msg) + def wait(self, *, seconds=None, until=None, reason=None, adjust=1): + now = datetime.datetime.now() + + if seconds: + seconds = float(seconds) + until = now + datetime.timedelta(seconds=seconds) + elif until: + until = datetime.datetime.fromtimestamp(float(until)) + seconds = (until - now).total_seconds() + else: + raise ValueError("Either 'seconds' or 'until' is required") + + if reason: + t = until.time() + isotime = "{:02}:{:02}:{:02}".format(t.hour, t.minute, t.second) + self.log.info("Waiting until %s for %s.", isotime, reason) + time.sleep(seconds + adjust) + def _get_auth_info(self): """Return authentication information as (username, password) tuple""" username = self.config("username") @@ -170,6 +188,9 @@ class Extractor(): def _init_cookies(self): """Populate the session's cookiejar""" + if self.cookiedomain is None: + return + cookies = self.config("cookies") if cookies: if isinstance(cookies, dict): |
