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.py28
1 files changed, 24 insertions, 4 deletions
diff --git a/gallery_dl/extractor/reddit.py b/gallery_dl/extractor/reddit.py
index 305de2a..cefe8d3 100644
--- a/gallery_dl/extractor/reddit.py
+++ b/gallery_dl/extractor/reddit.py
@@ -303,8 +303,8 @@ class RedditImageExtractor(Extractor):
category = "reddit"
subcategory = "image"
archive_fmt = "{filename}"
- pattern = (r"(?:https?://)?i\.redd(?:\.it|ituploads\.com)"
- r"/[^/?#]+(?:\?[^#]*)?")
+ pattern = (r"(?:https?://)?((?:i|preview)\.redd\.it|i\.reddituploads\.com)"
+ r"/([^/?#]+)(\?[^#]*)?")
test = (
("https://i.redd.it/upjtjcx2npzz.jpg", {
"url": "0de614900feef103e580b632190458c0b62b641a",
@@ -315,12 +315,29 @@ class RedditImageExtractor(Extractor):
"url": "f24f25efcedaddeec802e46c60d77ef975dc52a5",
"content": "541dbcc3ad77aa01ee21ca49843c5e382371fae7",
}),
+ # preview.redd.it -> i.redd.it
+ (("https://preview.redd.it/00af44lpn0u51.jpg?width=960&crop=smart"
+ "&auto=webp&v=enabled&s=dbca8ab84033f4a433772d9c15dbe0429c74e8ac"), {
+ "pattern": r"^https://i\.redd\.it/00af44lpn0u51\.jpg$"
+ }),
)
+ def __init__(self, match):
+ Extractor.__init__(self, match)
+ domain = match.group(1)
+ self.path = match.group(2)
+ if domain == "preview.redd.it":
+ self.domain = "i.redd.it"
+ self.query = ""
+ else:
+ self.domain = domain
+ self.query = match.group(3) or ""
+
def items(self):
- data = text.nameext_from_url(self.url)
+ url = "https://{}/{}{}".format(self.domain, self.path, self.query)
+ data = text.nameext_from_url(url)
yield Message.Directory, data
- yield Message.Url, self.url, data
+ yield Message.Url, url, data
class RedditAPI():
@@ -459,6 +476,9 @@ class RedditAPI():
def _pagination(self, endpoint, params):
id_min = self._parse_id("id-min", 0)
id_max = self._parse_id("id-max", float("inf"))
+ if id_max == 2147483647:
+ self.log.debug("Ignoring 'id-max' setting \"zik0zj\"")
+ id_max = float("inf")
date_min, date_max = self.extractor._get_date_min_max(0, 253402210800)
while True: