Skip to content
This repository was archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
Update techzapi.py
Browse files Browse the repository at this point in the history
  • Loading branch information
TechShreyash committed Jun 9, 2023
1 parent ca85a4d commit 001d07f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions utils/techzapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,26 @@ def gogo_stream(self, url):
return data["results"]


TOP_CACHE = {}


class TechZApi(Gogo):
def __init__(self, API_KEY) -> None:
self.base = "https://techzapi2.herokuapp.com"
self.api_key = API_KEY
super().__init__(API_KEY)

def top_animedex(self):
global TOP_CACHE

if time.time() - TOP_CACHE.get("time", 0) < 60 * 60 * 24:
print("from cache")
return TOP_CACHE["results"]
try:
data = (
requests.get("https://animedexapi2.herokuapp.com/top").json().get("top")
)
TOP_CACHE = {"time": time.time(), "results": data}
return data
except:
pass

0 comments on commit 001d07f

Please sign in to comment.