summaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/reddit.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@ubuntu.com>2019-07-20 05:51:44 -0400
committerLibravatarUnit 193 <unit193@ubuntu.com>2019-07-20 05:51:44 -0400
commit2a63a9c9b7032a76894c48ac4d9cea732fcaee49 (patch)
tree3d5f633ff69cd393036a3dabc4d4533c8484f9ad /gallery_dl/extractor/reddit.py
parent195c45911e79c33cf0bb986721365fb06df5a153 (diff)
New upstream version 1.9.0upstream/1.9.0
Diffstat (limited to 'gallery_dl/extractor/reddit.py')
-rw-r--r--gallery_dl/extractor/reddit.py19
1 files changed, 2 insertions, 17 deletions
diff --git a/gallery_dl/extractor/reddit.py b/gallery_dl/extractor/reddit.py
index 0c5a924..2ba4b99 100644
--- a/gallery_dl/extractor/reddit.py
+++ b/gallery_dl/extractor/reddit.py
@@ -11,7 +11,6 @@
from .common import Extractor, Message
from .. import text, util, extractor, exception
from ..cache import cache
-import datetime
import time
@@ -235,8 +234,7 @@ class RedditAPI():
url = "https://oauth.reddit.com" + endpoint
params["raw_json"] = 1
self.authenticate()
- response = self.extractor.request(
- url, params=params, expect=range(400, 500))
+ response = self.extractor.request(url, params=params, fatal=False)
remaining = response.headers.get("x-ratelimit-remaining")
if remaining and float(remaining) < 2:
wait = int(response.headers["x-ratelimit-reset"])
@@ -252,12 +250,9 @@ class RedditAPI():
return data
def _pagination(self, endpoint, params, _empty=()):
- date_fmt = self.extractor.config("date-format", "%Y-%m-%dT%H:%M:%S")
- date_min = self._parse_datetime("date-min", 0, date_fmt)
- date_max = self._parse_datetime("date-max", 253402210800, date_fmt)
-
id_min = self._parse_id("id-min", 0)
id_max = self._parse_id("id-max", 2147483647)
+ date_min, date_max = self.extractor._get_date_min_max(0, 253402210800)
while True:
data = self._call(endpoint, params)["data"]
@@ -294,16 +289,6 @@ class RedditAPI():
if link_id and extra:
yield from self.morechildren(link_id, extra)
- def _parse_datetime(self, key, default, fmt):
- ts = self.extractor.config(key, default)
- if isinstance(ts, str):
- try:
- ts = int(datetime.datetime.strptime(ts, fmt).timestamp())
- except ValueError as exc:
- self.log.warning("Unable to parse '%s': %s", key, exc)
- ts = default
- return ts
-
def _parse_id(self, key, default):
sid = self.extractor.config(key)
return self._decode(sid.rpartition("_")[2].lower()) if sid else default