diff --git a/gallery_dl/extractor/reddit.py b/gallery_dl/extractor/reddit.py index 05da7f4a44..55a7f65f2b 100644 --- a/gallery_dl/extractor/reddit.py +++ b/gallery_dl/extractor/reddit.py @@ -108,7 +108,11 @@ def items(self): if match: extra.append(match.group(1)) elif not match_user(url) and not match_subreddit(url): + if "preview" in data: + data["_fallback"] = self._previews(data) yield Message.Queue, text.unescape(url), data + if "_fallback" in data: + del data["_fallback"] if not extra or depth == max_depth: return @@ -165,6 +169,13 @@ def _extract_video(self, submission): submission["_ytdl_extra"] = {"title": submission["title"]} return submission["url"] + def _previews(self, post): + try: + for image in post["preview"]["images"]: + yield image["source"]["url"] + except Exception as exc: + self.log.debug("%s: %s", exc.__class__.__name__, exc) + class RedditSubredditExtractor(RedditExtractor): """Extractor for URLs from subreddits on reddit.com""" diff --git a/gallery_dl/job.py b/gallery_dl/job.py index af9241515e..5adb030cff 100644 --- a/gallery_dl/job.py +++ b/gallery_dl/job.py @@ -388,10 +388,23 @@ def handle_queue(self, url, kwdict): try: if pextr.config("parent-skip"): job._skipcnt = self._skipcnt - self.status |= job.run() + status = job.run() self._skipcnt = job._skipcnt else: - self.status |= job.run() + status = job.run() + + if status: + self.status |= status + if "_fallback" in kwdict and self.fallback: + fallback = kwdict["_fallback"] = \ + iter(kwdict["_fallback"]) + try: + url = next(fallback) + except StopIteration: + pass + else: + text.nameext_from_url(url, kwdict) + self.handle_url(url, kwdict) break except exception.RestartExtraction: pass