diff --git a/gallery_dl/extractor/common.py b/gallery_dl/extractor/common.py index 72ed910f..98cd61fb 100644 --- a/gallery_dl/extractor/common.py +++ b/gallery_dl/extractor/common.py @@ -93,7 +93,8 @@ class Extractor(): pass def items(self): - yield Message.Version, 1 + return + yield def skip(self, num): return 0 @@ -919,7 +920,7 @@ class Dispatch(): elif isinstance(include, str): include = include.replace(" ", "").split(",") - results = [(Message.Version, 1)] + results = [] for category in include: try: extr, url = extractors[category] diff --git a/gallery_dl/extractor/message.py b/gallery_dl/extractor/message.py index ee61c10a..6eda2134 100644 --- a/gallery_dl/extractor/message.py +++ b/gallery_dl/extractor/message.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2015-2021 Mike Fährmann +# Copyright 2015-2025 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 @@ -14,7 +14,7 @@ class Message(): is one of the following identifiers. This message-identifier determines the type and meaning of the other elements in such a tuple. - - Message.Version: + - Message.Version: # obsolete - Message protocol version (currently always '1') - 2nd element specifies the version of all following messages as integer @@ -46,7 +46,7 @@ class Message(): - The additional URLs serve as a fallback if the primary one fails """ - Version = 1 + # Version = 1 Directory = 2 Url = 3 # Headers = 4 diff --git a/gallery_dl/extractor/noop.py b/gallery_dl/extractor/noop.py index df2316c4..fe88e63b 100644 --- a/gallery_dl/extractor/noop.py +++ b/gallery_dl/extractor/noop.py @@ -8,7 +8,7 @@ """noop extractor""" -from .common import Extractor, Message +from .common import Extractor class NoopExtractor(Extractor): @@ -17,11 +17,9 @@ class NoopExtractor(Extractor): example = "noop" def items(self): - # yield *something* to prevent a 'No results' message - yield Message.Version, 1 - # Save cookies manually, since it happens automatically only after # extended extractor initialization, i.e. Message.Directory, which # itself might cause some unintended effects. if self.cookies: self.cookies_store() + return iter(((-1, "", None),)) diff --git a/gallery_dl/extractor/oauth.py b/gallery_dl/extractor/oauth.py index d1b2c956..37192eb1 100644 --- a/gallery_dl/extractor/oauth.py +++ b/gallery_dl/extractor/oauth.py @@ -8,7 +8,7 @@ """Utility classes to setup OAuth and link accounts to gallery-dl""" -from .common import Extractor, Message +from .common import Extractor from .. import text, oauth, util, config, exception from ..output import stdout_write from ..cache import cache, memcache @@ -18,6 +18,7 @@ import hashlib REDIRECT_URI_LOCALHOST = "http://localhost:6414/" REDIRECT_URI_HTTPS = "https://mikf.github.io/gallery-dl/oauth-redirect.html" +NOOP = ((-1, "", None),) class OAuthBase(Extractor): @@ -257,7 +258,6 @@ class OAuthFlickr(OAuthBase): redirect_uri = REDIRECT_URI_HTTPS def items(self): - yield Message.Version, 1 # from . import flickr self._oauth1_authorization_flow( @@ -269,6 +269,7 @@ class OAuthFlickr(OAuthBase): "https://www.flickr.com/services/oauth/authorize", "https://www.flickr.com/services/oauth/access_token", ) + return iter(NOOP) class OAuthSmugmug(OAuthBase): @@ -277,7 +278,6 @@ class OAuthSmugmug(OAuthBase): example = "oauth:smugmug" def items(self): - yield Message.Version, 1 from . import smugmug self._oauth1_authorization_flow( @@ -287,6 +287,7 @@ class OAuthSmugmug(OAuthBase): "https://api.smugmug.com/services/oauth/1.0a/authorize", "https://api.smugmug.com/services/oauth/1.0a/getAccessToken", ) + return iter(NOOP) class OAuthTumblr(OAuthBase): @@ -295,7 +296,6 @@ class OAuthTumblr(OAuthBase): example = "oauth:tumblr" def items(self): - yield Message.Version, 1 from . import tumblr self._oauth1_authorization_flow( @@ -305,6 +305,7 @@ class OAuthTumblr(OAuthBase): "https://www.tumblr.com/oauth/authorize", "https://www.tumblr.com/oauth/access_token", ) + return iter(NOOP) # -------------------------------------------------------------------- @@ -317,7 +318,6 @@ class OAuthDeviantart(OAuthBase): redirect_uri = REDIRECT_URI_HTTPS def items(self): - yield Message.Version, 1 from . import deviantart self._oauth2_authorization_code_grant( @@ -330,6 +330,7 @@ class OAuthDeviantart(OAuthBase): scope="browse user.manage", cache=deviantart._refresh_token_cache, ) + return iter(NOOP) class OAuthReddit(OAuthBase): @@ -338,7 +339,6 @@ class OAuthReddit(OAuthBase): example = "oauth:reddit" def items(self): - yield Message.Version, 1 from . import reddit self.session.headers["User-Agent"] = reddit.RedditAPI.USER_AGENT @@ -352,6 +352,7 @@ class OAuthReddit(OAuthBase): scope="read history", cache=reddit._refresh_token_cache, ) + return iter(NOOP) class OAuthMastodon(OAuthBase): @@ -364,7 +365,6 @@ class OAuthMastodon(OAuthBase): self.instance = match[1] def items(self): - yield Message.Version, 1 from . import mastodon for _, root, application in mastodon.MastodonExtractor.instances: @@ -384,6 +384,7 @@ class OAuthMastodon(OAuthBase): key="access_token", cache=mastodon._access_token_cache, ) + return iter(NOOP) @cache(maxage=36500*86400, keyarg=1) def _register(self, instance): @@ -418,7 +419,6 @@ class OAuthPixiv(OAuthBase): example = "oauth:pixiv" def items(self): - yield Message.Version, 1 from . import pixiv code_verifier = util.generate_token(32) @@ -466,6 +466,7 @@ class OAuthPixiv(OAuthBase): self.log.info("Writing 'refresh-token' to cache") stdout_write(self._generate_message(("refresh-token",), (token,))) + return iter(NOOP) def _input_code(self): stdout_write("""\ diff --git a/test/test_extractor.py b/test/test_extractor.py index 4398df79..c06b890c 100644 --- a/test/test_extractor.py +++ b/test/test_extractor.py @@ -39,7 +39,7 @@ class FakeExtractor(Extractor): pattern = "fake:" def items(self): - yield Message.Version, 1 + yield Message.Noop yield Message.Url, "text:foobar", {}