adjust cache maxage values

This commit is contained in:
Mike Fährmann
2019-03-14 22:21:49 +01:00
parent f612284d24
commit a2af2d2965
13 changed files with 19 additions and 19 deletions

View File

@@ -665,7 +665,7 @@ class DeviantartAPI():
"""Authenticate the application by requesting an access token""" """Authenticate the application by requesting an access token"""
self.headers["Authorization"] = self._authenticate_impl(refresh_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): def _authenticate_impl(self, refresh_token):
"""Actual authenticate implementation""" """Actual authenticate implementation"""
url = "https://www.deviantart.com/oauth2/token" url = "https://www.deviantart.com/oauth2/token"
@@ -748,7 +748,7 @@ class DeviantartAPI():
return result 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): def _refresh_token_cache(original_token, new_token=None):
return new_token or original_token return new_token or original_token

View File

@@ -72,7 +72,7 @@ class ExhentaiExtractor(Extractor):
self.limits = False self.limits = False
self.session.cookies["nw"] = "1" 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): def _login_impl(self, username, password):
self.log.info("Logging in as %s", username) self.log.info("Logging in as %s", username)
url = "https://forums.e-hentai.org/index.php?act=Login&CODE=01" url = "https://forums.e-hentai.org/index.php?act=Login&CODE=01"

View File

@@ -163,7 +163,7 @@ class ImagetwistImageExtractor(ImagehostImageExtractor):
params = None params = None
@property @property
@memcache(maxage=3*60*60) @memcache(maxage=3*3600)
def cookies(self): def cookies(self):
return self.request(self.page_url).cookies return self.request(self.page_url).cookies

View File

@@ -25,7 +25,7 @@ class LusciousExtractor(Extractor):
if username: if username:
self._update_cookies(self._login_impl(username, password)) 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): def _login_impl(self, username, password):
self.log.info("Logging in as %s", username) self.log.info("Logging in as %s", username)
url = "https://members.luscious.net/accounts/login/" url = "https://members.luscious.net/accounts/login/"

View File

@@ -10,6 +10,7 @@
from .common import Extractor, Message from .common import Extractor, Message
from .. import text, util from .. import text, util
from ..cache import memcache
class MangadexExtractor(Extractor): class MangadexExtractor(Extractor):
@@ -30,12 +31,11 @@ class MangadexExtractor(Extractor):
url = "{}/api/chapter/{}".format(self.root, chapter_id) url = "{}/api/chapter/{}".format(self.root, chapter_id)
return self.request(url).json() 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'""" """Request API results for 'manga_id'"""
if manga_id not in cache: url = "{}/api/manga/{}".format(self.root, manga_id)
url = "{}/api/manga/{}".format(self.root, manga_id) return self.request(url).json()
cache[manga_id] = self.request(url).json()
return cache[manga_id]
class MangadexChapterExtractor(MangadexExtractor): class MangadexChapterExtractor(MangadexExtractor):

View File

@@ -90,7 +90,7 @@ class NijieExtractor(AsynchronousMixin, Extractor):
username, password = self._get_auth_info() username, password = self._get_auth_info()
self._update_cookies(self._login_impl(username, password)) 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): def _login_impl(self, username, password):
self.log.info("Logging in as %s", username) self.log.info("Logging in as %s", username)
url = "{}/login_int.php".format(self.root) url = "{}/login_int.php".format(self.root)

View File

@@ -283,7 +283,7 @@ class OAuthMastodon(OAuthBase):
message_template=MASTODON_MSG_TEMPLATE, 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): def _register(self, instance):
self.log.info("Registering application for '%s'", instance) self.log.info("Registering application for '%s'", instance)

View File

@@ -423,7 +423,7 @@ class PixivAppAPI():
self.user, auth = self._login_impl(self.username, self.password) self.user, auth = self._login_impl(self.username, self.password)
self.extractor.session.headers["Authorization"] = auth self.extractor.session.headers["Authorization"] = auth
@cache(maxage=3590, keyarg=1) @cache(maxage=3600, keyarg=1)
def _login_impl(self, username, password): def _login_impl(self, username, password):
url = "https://oauth.secure.pixiv.net/auth/token" url = "https://oauth.secure.pixiv.net/auth/token"
data = { data = {
@@ -511,6 +511,6 @@ class PixivAppAPI():
params = text.parse_query(query) 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): def _refresh_token_cache(username):
return None return None

View File

@@ -211,7 +211,7 @@ class RedditAPI():
access_token = self._authenticate_impl(self.refresh_token) access_token = self._authenticate_impl(self.refresh_token)
self.extractor.session.headers["Authorization"] = access_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): def _authenticate_impl(self, refresh_token=None):
"""Actual authenticate implementation""" """Actual authenticate implementation"""
url = "https://www.reddit.com/api/v1/access_token" url = "https://www.reddit.com/api/v1/access_token"

View File

@@ -123,7 +123,7 @@ class SankakuExtractor(SharedConfigMixin, Extractor):
else: else:
self.logged_in = False 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): def _login_impl(self, usertuple, password):
username = usertuple[0] username = usertuple[0]
self.log.info("Logging in as %s", username) self.log.info("Logging in as %s", username)

View File

@@ -54,7 +54,7 @@ class SeigaExtractor(Extractor):
username, password = self._get_auth_info() username, password = self._get_auth_info()
self._update_cookies(self._login_impl(username, password)) 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): def _login_impl(self, username, password):
self.log.info("Logging in as %s", username) self.log.info("Logging in as %s", username)
url = "https://account.nicovideo.jp/api/v1/login" url = "https://account.nicovideo.jp/api/v1/login"

View File

@@ -27,7 +27,7 @@ class TsuminoBase():
self.session.cookies.setdefault( self.session.cookies.setdefault(
"ASP.NET_SessionId", "x1drgggilez4cpkttneukrc5") "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): def _login_impl(self, username, password):
self.log.info("Logging in as %s", username) self.log.info("Logging in as %s", username)
url = "{}/Account/Login".format(self.root) url = "{}/Account/Login".format(self.root)

View File

@@ -25,7 +25,7 @@ class WallhavenExtractor(Extractor):
if username: if username:
self._update_cookies(self._login_impl(username, password)) 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): def _login_impl(self, username, password):
self.log.info("Logging in as %s", username) self.log.info("Logging in as %s", username)
url = "{}/auth/login".format(self.root) url = "{}/auth/login".format(self.root)