From b8a702929d7eda99a9987b68c79eb4dc61d71e24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Thu, 2 Mar 2023 18:39:54 +0100 Subject: [PATCH] [oauth] import extractor modules on demand --- gallery_dl/extractor/oauth.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gallery_dl/extractor/oauth.py b/gallery_dl/extractor/oauth.py index 55407947..ec46ca3b 100644 --- a/gallery_dl/extractor/oauth.py +++ b/gallery_dl/extractor/oauth.py @@ -9,7 +9,6 @@ """Utility classes to setup OAuth and link accounts to gallery-dl""" from .common import Extractor, Message -from . import deviantart, flickr, mastodon, pixiv, reddit, smugmug, tumblr from .. import text, oauth, util, config, exception from ..output import stdout_write from ..cache import cache @@ -243,6 +242,7 @@ class OAuthFlickr(OAuthBase): def items(self): yield Message.Version, 1 + from . import flickr self._oauth1_authorization_flow( flickr.FlickrAPI.API_KEY, @@ -259,6 +259,7 @@ class OAuthSmugmug(OAuthBase): def items(self): yield Message.Version, 1 + from . import smugmug self._oauth1_authorization_flow( smugmug.SmugmugAPI.API_KEY, @@ -275,6 +276,7 @@ class OAuthTumblr(OAuthBase): def items(self): yield Message.Version, 1 + from . import tumblr self._oauth1_authorization_flow( tumblr.TumblrAPI.API_KEY, @@ -295,6 +297,7 @@ class OAuthDeviantart(OAuthBase): def items(self): yield Message.Version, 1 + from . import deviantart self._oauth2_authorization_code_grant( self.oauth_config("client-id"), @@ -314,6 +317,7 @@ class OAuthReddit(OAuthBase): def items(self): yield Message.Version, 1 + from . import reddit self.session.headers["User-Agent"] = reddit.RedditAPI.USER_AGENT self._oauth2_authorization_code_grant( @@ -338,6 +342,7 @@ class OAuthMastodon(OAuthBase): def items(self): yield Message.Version, 1 + from . import mastodon for application in mastodon.INSTANCES.values(): if self.instance == application["root"].partition("://")[2]: @@ -390,6 +395,7 @@ class OAuthPixiv(OAuthBase): def items(self): yield Message.Version, 1 + from . import pixiv code_verifier = util.generate_token(32) digest = hashlib.sha256(code_verifier.encode()).digest()