From a2af2d2965527ea2421ccc3ba324379b4bd1486a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Thu, 14 Mar 2019 22:21:49 +0100 Subject: [PATCH] adjust cache maxage values --- gallery_dl/extractor/deviantart.py | 4 ++-- gallery_dl/extractor/exhentai.py | 2 +- gallery_dl/extractor/imagehosts.py | 2 +- gallery_dl/extractor/luscious.py | 2 +- gallery_dl/extractor/mangadex.py | 10 +++++----- gallery_dl/extractor/nijie.py | 2 +- gallery_dl/extractor/oauth.py | 2 +- gallery_dl/extractor/pixiv.py | 4 ++-- gallery_dl/extractor/reddit.py | 2 +- gallery_dl/extractor/sankaku.py | 2 +- gallery_dl/extractor/seiga.py | 2 +- gallery_dl/extractor/tsumino.py | 2 +- gallery_dl/extractor/wallhaven.py | 2 +- 13 files changed, 19 insertions(+), 19 deletions(-) diff --git a/gallery_dl/extractor/deviantart.py b/gallery_dl/extractor/deviantart.py index a9aae5fb..7e0ddc58 100644 --- a/gallery_dl/extractor/deviantart.py +++ b/gallery_dl/extractor/deviantart.py @@ -665,7 +665,7 @@ class DeviantartAPI(): """Authenticate the application by requesting an access token""" self.headers["Authorization"] = self._authenticate_impl(refresh_token) - @cache(maxage=3590, keyarg=1) + @cache(maxage=3600, keyarg=1) def _authenticate_impl(self, refresh_token): """Actual authenticate implementation""" url = "https://www.deviantart.com/oauth2/token" @@ -748,7 +748,7 @@ class DeviantartAPI(): return result -@cache(maxage=365*24*60*60, keyarg=0) +@cache(maxage=10*365*24*3600, keyarg=0) def _refresh_token_cache(original_token, new_token=None): return new_token or original_token diff --git a/gallery_dl/extractor/exhentai.py b/gallery_dl/extractor/exhentai.py index 9ea1ebe9..4067be22 100644 --- a/gallery_dl/extractor/exhentai.py +++ b/gallery_dl/extractor/exhentai.py @@ -72,7 +72,7 @@ class ExhentaiExtractor(Extractor): self.limits = False self.session.cookies["nw"] = "1" - @cache(maxage=90*24*60*60, keyarg=1) + @cache(maxage=90*24*3600, keyarg=1) def _login_impl(self, username, password): self.log.info("Logging in as %s", username) url = "https://forums.e-hentai.org/index.php?act=Login&CODE=01" diff --git a/gallery_dl/extractor/imagehosts.py b/gallery_dl/extractor/imagehosts.py index e4d05d35..954c1f00 100644 --- a/gallery_dl/extractor/imagehosts.py +++ b/gallery_dl/extractor/imagehosts.py @@ -163,7 +163,7 @@ class ImagetwistImageExtractor(ImagehostImageExtractor): params = None @property - @memcache(maxage=3*60*60) + @memcache(maxage=3*3600) def cookies(self): return self.request(self.page_url).cookies diff --git a/gallery_dl/extractor/luscious.py b/gallery_dl/extractor/luscious.py index 1a3b2b75..d27f20c5 100644 --- a/gallery_dl/extractor/luscious.py +++ b/gallery_dl/extractor/luscious.py @@ -25,7 +25,7 @@ class LusciousExtractor(Extractor): if username: self._update_cookies(self._login_impl(username, password)) - @cache(maxage=14*24*60*60, keyarg=1) + @cache(maxage=14*24*3600, keyarg=1) def _login_impl(self, username, password): self.log.info("Logging in as %s", username) url = "https://members.luscious.net/accounts/login/" diff --git a/gallery_dl/extractor/mangadex.py b/gallery_dl/extractor/mangadex.py index e00fdfde..d0eb2a96 100644 --- a/gallery_dl/extractor/mangadex.py +++ b/gallery_dl/extractor/mangadex.py @@ -10,6 +10,7 @@ from .common import Extractor, Message from .. import text, util +from ..cache import memcache class MangadexExtractor(Extractor): @@ -30,12 +31,11 @@ class MangadexExtractor(Extractor): url = "{}/api/chapter/{}".format(self.root, chapter_id) return self.request(url).json() - def manga_data(self, manga_id, *, cache={}): + @memcache(keyarg=1) + def manga_data(self, manga_id): """Request API results for 'manga_id'""" - if manga_id not in cache: - url = "{}/api/manga/{}".format(self.root, manga_id) - cache[manga_id] = self.request(url).json() - return cache[manga_id] + url = "{}/api/manga/{}".format(self.root, manga_id) + return self.request(url).json() class MangadexChapterExtractor(MangadexExtractor): diff --git a/gallery_dl/extractor/nijie.py b/gallery_dl/extractor/nijie.py index 4f7bbe6e..abf1eaa6 100644 --- a/gallery_dl/extractor/nijie.py +++ b/gallery_dl/extractor/nijie.py @@ -90,7 +90,7 @@ class NijieExtractor(AsynchronousMixin, Extractor): username, password = self._get_auth_info() self._update_cookies(self._login_impl(username, password)) - @cache(maxage=150*24*60*60, keyarg=1) + @cache(maxage=150*24*3600, keyarg=1) def _login_impl(self, username, password): self.log.info("Logging in as %s", username) url = "{}/login_int.php".format(self.root) diff --git a/gallery_dl/extractor/oauth.py b/gallery_dl/extractor/oauth.py index 51b22149..e26eae18 100644 --- a/gallery_dl/extractor/oauth.py +++ b/gallery_dl/extractor/oauth.py @@ -283,7 +283,7 @@ class OAuthMastodon(OAuthBase): message_template=MASTODON_MSG_TEMPLATE, ) - @cache(maxage=10*365*24*60*60, keyarg=1) + @cache(maxage=10*365*24*3600, keyarg=1) def _register(self, instance): self.log.info("Registering application for '%s'", instance) diff --git a/gallery_dl/extractor/pixiv.py b/gallery_dl/extractor/pixiv.py index a68455d7..42853ea6 100644 --- a/gallery_dl/extractor/pixiv.py +++ b/gallery_dl/extractor/pixiv.py @@ -423,7 +423,7 @@ class PixivAppAPI(): self.user, auth = self._login_impl(self.username, self.password) self.extractor.session.headers["Authorization"] = auth - @cache(maxage=3590, keyarg=1) + @cache(maxage=3600, keyarg=1) def _login_impl(self, username, password): url = "https://oauth.secure.pixiv.net/auth/token" data = { @@ -511,6 +511,6 @@ class PixivAppAPI(): params = text.parse_query(query) -@cache(maxage=365*24*60*60, keyarg=0) +@cache(maxage=10*365*24*3600, keyarg=0) def _refresh_token_cache(username): return None diff --git a/gallery_dl/extractor/reddit.py b/gallery_dl/extractor/reddit.py index fb446b73..0c5a9245 100644 --- a/gallery_dl/extractor/reddit.py +++ b/gallery_dl/extractor/reddit.py @@ -211,7 +211,7 @@ class RedditAPI(): access_token = self._authenticate_impl(self.refresh_token) self.extractor.session.headers["Authorization"] = access_token - @cache(maxage=3590, keyarg=1) + @cache(maxage=3600, keyarg=1) def _authenticate_impl(self, refresh_token=None): """Actual authenticate implementation""" url = "https://www.reddit.com/api/v1/access_token" diff --git a/gallery_dl/extractor/sankaku.py b/gallery_dl/extractor/sankaku.py index 2c47930e..8bf6bcf8 100644 --- a/gallery_dl/extractor/sankaku.py +++ b/gallery_dl/extractor/sankaku.py @@ -123,7 +123,7 @@ class SankakuExtractor(SharedConfigMixin, Extractor): else: self.logged_in = False - @cache(maxage=90*24*60*60, keyarg=1) + @cache(maxage=90*24*3600, keyarg=1) def _login_impl(self, usertuple, password): username = usertuple[0] self.log.info("Logging in as %s", username) diff --git a/gallery_dl/extractor/seiga.py b/gallery_dl/extractor/seiga.py index 6b391b5c..f63c9997 100644 --- a/gallery_dl/extractor/seiga.py +++ b/gallery_dl/extractor/seiga.py @@ -54,7 +54,7 @@ class SeigaExtractor(Extractor): username, password = self._get_auth_info() self._update_cookies(self._login_impl(username, password)) - @cache(maxage=7*24*60*60, keyarg=1) + @cache(maxage=7*24*3600, keyarg=1) def _login_impl(self, username, password): self.log.info("Logging in as %s", username) url = "https://account.nicovideo.jp/api/v1/login" diff --git a/gallery_dl/extractor/tsumino.py b/gallery_dl/extractor/tsumino.py index ec80c78d..834ce47f 100644 --- a/gallery_dl/extractor/tsumino.py +++ b/gallery_dl/extractor/tsumino.py @@ -27,7 +27,7 @@ class TsuminoBase(): self.session.cookies.setdefault( "ASP.NET_SessionId", "x1drgggilez4cpkttneukrc5") - @cache(maxage=14*24*60*60, keyarg=1) + @cache(maxage=14*24*3600, keyarg=1) def _login_impl(self, username, password): self.log.info("Logging in as %s", username) url = "{}/Account/Login".format(self.root) diff --git a/gallery_dl/extractor/wallhaven.py b/gallery_dl/extractor/wallhaven.py index c3f54ef9..c107a467 100644 --- a/gallery_dl/extractor/wallhaven.py +++ b/gallery_dl/extractor/wallhaven.py @@ -25,7 +25,7 @@ class WallhavenExtractor(Extractor): if username: self._update_cookies(self._login_impl(username, password)) - @cache(maxage=365*24*60*60, keyarg=1) + @cache(maxage=365*24*3600, keyarg=1) def _login_impl(self, username, password): self.log.info("Logging in as %s", username) url = "{}/auth/login".format(self.root)