summaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/reddit.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/extractor/reddit.py')
-rw-r--r--gallery_dl/extractor/reddit.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/gallery_dl/extractor/reddit.py b/gallery_dl/extractor/reddit.py
index 656148e..4c83019 100644
--- a/gallery_dl/extractor/reddit.py
+++ b/gallery_dl/extractor/reddit.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2017-2019 Mike Fährmann
+# Copyright 2017-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
@@ -11,12 +11,12 @@
from .common import Extractor, Message
from .. import text, util, extractor, exception
from ..cache import cache
-import time
class RedditExtractor(Extractor):
"""Base class for reddit extractors"""
category = "reddit"
+ cookiedomain = None
def __init__(self, match):
Extractor.__init__(self, match)
@@ -277,11 +277,13 @@ class RedditAPI():
params["raw_json"] = 1
self.authenticate()
response = self.extractor.request(url, params=params, fatal=None)
+
remaining = response.headers.get("x-ratelimit-remaining")
if remaining and float(remaining) < 2:
- wait = int(response.headers["x-ratelimit-reset"])
- self.log.info("Waiting %d seconds for ratelimit reset", wait)
- time.sleep(wait)
+ reset = response.headers["x-ratelimit-reset"]
+ self.extractor.wait(seconds=reset, reason="rate limit reset")
+ return self._call(endpoint, params)
+
data = response.json()
if "error" in data:
if data["error"] == 403: