From 0a94fe5774626243a2b49ce5f0cc73bd66ee67ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Mon, 30 Aug 2021 22:39:40 +0200 Subject: [PATCH] [reddit] delay RedditAPI initialization (#1813) Move it outside the constructor so that eventual exceptions can get caught in the expected places. --- gallery_dl/extractor/reddit.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/gallery_dl/extractor/reddit.py b/gallery_dl/extractor/reddit.py index 8ea8190b..dcb182ae 100644 --- a/gallery_dl/extractor/reddit.py +++ b/gallery_dl/extractor/reddit.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2017-2020 Mike Fährmann +# Copyright 2017-2021 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 @@ -21,17 +21,14 @@ class RedditExtractor(Extractor): archive_fmt = "{filename}" cookiedomain = None - def __init__(self, match): - Extractor.__init__(self, match) - self.api = RedditAPI(self) - self.max_depth = self.config("recursion", 0) - def items(self): + self.api = RedditAPI(self) match_submission = RedditSubmissionExtractor.pattern.match match_subreddit = RedditSubredditExtractor.pattern.match match_user = RedditUserExtractor.pattern.match parentdir = self.config("parent-directory") + max_depth = self.config("recursion", 0) videos = self.config("videos", True) submissions = self.submissions() @@ -103,7 +100,7 @@ class RedditExtractor(Extractor): elif not match_user(url) and not match_subreddit(url): yield Message.Queue, text.unescape(url), data - if not extra or depth == self.max_depth: + if not extra or depth == max_depth: return depth += 1 submissions = (