diff --git a/gallery_dl/extractor/oauth.py b/gallery_dl/extractor/oauth.py index 4bb2c482..ab1c7931 100644 --- a/gallery_dl/extractor/oauth.py +++ b/gallery_dl/extractor/oauth.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 @@ -9,7 +9,7 @@ """Utility classes to setup OAuth and link accounts to gallery-dl""" from .common import Extractor, Message -from . import deviantart, flickr, reddit, smugmug, tumblr +from . import deviantart, flickr, mastodon, reddit, smugmug, tumblr from .. import text, oauth, util, config, exception from ..cache import cache import urllib.parse @@ -324,8 +324,10 @@ class OAuthMastodon(OAuthBase): def items(self): yield Message.Version, 1 - application = self.oauth_config(self.instance) - if not application: + for application in mastodon.INSTANCES.values(): + if self.instance == application["root"].partition("://")[2]: + break + else: application = self._register(self.instance) self._oauth2_authorization_code_grant( diff --git a/test/test_extractor.py b/test/test_extractor.py index 8bc3a278..f04e1c71 100644 --- a/test/test_extractor.py +++ b/test/test_extractor.py @@ -219,10 +219,6 @@ class TestExtractorWait(unittest.TestCase): class TextExtractorOAuth(unittest.TestCase): - @classmethod - def setUpClass(cls): - mastodon.generate_extractors() - def test_oauth1(self): for category in ("flickr", "smugmug", "tumblr"): extr = extractor.find("oauth:" + category)