aboutsummaryrefslogtreecommitdiffstats
path: root/gallery_dl/oauth.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2020-06-01 23:11:37 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2020-06-01 23:11:37 -0400
commita70a3246927b72f1ded37acd55ee719515441b5b (patch)
tree57f0d3ab0b1387b665325f42a24b8aab63cbce07 /gallery_dl/oauth.py
parent90e50db2e3c38f523bb5195d295290b06e5cedb0 (diff)
New upstream version 1.14.0.upstream/1.14.0
Diffstat (limited to 'gallery_dl/oauth.py')
-rw-r--r--gallery_dl/oauth.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/gallery_dl/oauth.py b/gallery_dl/oauth.py
index 9ceefbf..e9dfff0 100644
--- a/gallery_dl/oauth.py
+++ b/gallery_dl/oauth.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2018-2019 Mike Fährmann
+# Copyright 2018-2020 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
@@ -20,6 +20,7 @@ import requests
import requests.auth
from . import text
+from .cache import cache
def nonce(size, alphabet=string.ascii_letters):
@@ -117,6 +118,10 @@ class OAuth1API():
token_secret = extractor.config("access-token-secret")
key_type = "default" if api_key == self.API_KEY else "custom"
+ if token is None or token == "cache":
+ key = (extractor.category, api_key)
+ token, token_secret = _token_cache(key)
+
if api_key and api_secret and token and token_secret:
self.log.debug("Using %s OAuth1.0 authentication", key_type)
self.session = OAuth1Session(
@@ -131,3 +136,8 @@ class OAuth1API():
kwargs["fatal"] = None
kwargs["session"] = self.session
return self.extractor.request(url, **kwargs)
+
+
+@cache(maxage=100*365*24*3600, keyarg=0)
+def _token_cache(key):
+ return None, None