LRU cache
parent
3375c1073f
commit
155df83abe
|
@ -3,7 +3,7 @@ import requests
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
import traceback
|
import traceback
|
||||||
import backoff
|
import backoff
|
||||||
from functools import cache
|
from functools import lru_cache
|
||||||
|
|
||||||
class TimeOutException(Exception):
|
class TimeOutException(Exception):
|
||||||
pass
|
pass
|
||||||
|
@ -16,11 +16,13 @@ class RDramaAPIInterface:
|
||||||
self.headers={"Authorization": authorization_token}
|
self.headers={"Authorization": authorization_token}
|
||||||
self.site = site
|
self.site = site
|
||||||
self.protocol = "https" if https else "http"
|
self.protocol = "https" if https else "http"
|
||||||
|
self.user_information = None
|
||||||
|
self.badge_refresh = False
|
||||||
|
|
||||||
def is_chudded(self):
|
def is_chudded(self):
|
||||||
return "Chud" in self.get_my_badges_simple()
|
return "Chud" in self.get_my_badges_simple()
|
||||||
|
|
||||||
@cache
|
@lru_cache(maxsize=None)
|
||||||
def get_my_badges_simple(self):
|
def get_my_badges_simple(self):
|
||||||
return [i['name'] for i in self.get_my_badges()]
|
return [i['name'] for i in self.get_my_badges()]
|
||||||
|
|
||||||
|
@ -31,7 +33,7 @@ class RDramaAPIInterface:
|
||||||
url=f"{self.protocol}://{self.site}/submit"
|
url=f"{self.protocol}://{self.site}/submit"
|
||||||
return self.post(url, data={'title' : title, 'url': submission_url, 'body': body})
|
return self.post(url, data={'title' : title, 'url': submission_url, 'body': body})
|
||||||
|
|
||||||
@cache
|
@lru_cache(maxsize=None)
|
||||||
def get_me(self):
|
def get_me(self):
|
||||||
self.get_front_page()
|
self.get_front_page()
|
||||||
url=f"{self.protocol}://{self.site}/@me"
|
url=f"{self.protocol}://{self.site}/@me"
|
||||||
|
@ -124,6 +126,7 @@ class RDramaAPIInterface:
|
||||||
|
|
||||||
def get_front_page(self):
|
def get_front_page(self):
|
||||||
url=f"{self.protocol}://{self.site}"
|
url=f"{self.protocol}://{self.site}"
|
||||||
|
self.badge_refresh = True
|
||||||
return self.get(url)
|
return self.get(url)
|
||||||
|
|
||||||
def get_hole(self, hole: str):
|
def get_hole(self, hole: str):
|
||||||
|
@ -136,7 +139,8 @@ class RDramaAPIInterface:
|
||||||
|
|
||||||
def get_user_information(self, id):
|
def get_user_information(self, id):
|
||||||
url=f"{self.protocol}://{self.site}/{id}/info"
|
url=f"{self.protocol}://{self.site}/{id}/info"
|
||||||
return self.get(url)
|
self.user_information = self.get(url)
|
||||||
|
return result
|
||||||
'''
|
'''
|
||||||
I have no clue what this is supposed to do, lol.
|
I have no clue what this is supposed to do, lol.
|
||||||
'''
|
'''
|
||||||
|
|
Loading…
Reference in New Issue