add time ago on recent items

+ move to waitress wsgi server
+ refactor dates utils
+ create locustfile for stress test
This commit is contained in:
mungai-njoroge
2024-02-11 21:10:52 +03:00
parent cb47a4bc6e
commit b7e86ed79b
8 changed files with 707 additions and 74 deletions
+8 -1
View File
@@ -47,6 +47,7 @@ class LyricsProvider(LRCProvider):
"""
ROOT_URL = Keys.PLUGIN_LYRICS_ROOT_URL
get_token_trials = 0
def __init__(self) -> None:
super().__init__()
@@ -85,6 +86,10 @@ class LyricsProvider(LRCProvider):
return None
def _get_token(self):
if self.get_token_trials > 3:
self.get_token_trials = 0
return
# Check if token is cached and not expired
plugin_path = Paths.get_lyrics_plugins_path()
token_path = os.path.join(plugin_path, "token.json")
@@ -110,11 +115,13 @@ class LyricsProvider(LRCProvider):
res = res.json()
if res["message"]["header"]["status_code"] == 401:
time.sleep(10)
time.sleep(13)
self.get_token_trials += 1
return self._get_token()
new_token = res["message"]["body"]["user_token"]
expiration_time = current_time + 600 # 10 minutes expiration
self.get_token_trials = 0
# Cache the new token
self.token = new_token