Update main.py
Browse files
main.py
CHANGED
@@ -9,10 +9,10 @@ import requests
|
|
9 |
from bs4 import BeautifulSoup
|
10 |
import validators
|
11 |
from youtube_transcript_api import YouTubeTranscriptApi
|
12 |
-
from cachetools import TTLCache
|
13 |
-
import asyncio
|
14 |
-
import hashlib
|
15 |
-
import time
|
16 |
|
17 |
|
18 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
@@ -243,7 +243,7 @@ def extract_transcript(youtube_link):
|
|
243 |
# raise HTTPException(status_code=500, detail="Internal Server Error")
|
244 |
|
245 |
|
246 |
-
cache={}
|
247 |
|
248 |
# @app.on_event("startup")
|
249 |
# async def startup_event():
|
@@ -262,18 +262,10 @@ cache={}
|
|
262 |
@app.get("/summary")
|
263 |
async def test(url:str):
|
264 |
try:
|
265 |
-
cache_key = hashlib.sha256(url.encode()).hexdigest()
|
266 |
-
print(cache_key)
|
267 |
-
# Check if the response is already cached
|
268 |
-
if cache_key in cache:
|
269 |
-
print("hi")
|
270 |
-
return cache[cache_key]
|
271 |
-
|
272 |
status,content=scrweb(url)
|
273 |
if status==200:
|
274 |
response=genetate_gemini_content(prompt6,content)
|
275 |
print(response)
|
276 |
-
cache[cache_key]=response
|
277 |
return response
|
278 |
else:
|
279 |
return status
|
@@ -352,7 +344,6 @@ async def test():
|
|
352 |
|
353 |
|
354 |
|
355 |
-
|
356 |
@app.get("/rm")
|
357 |
async def rm():
|
358 |
global transcript
|
|
|
9 |
from bs4 import BeautifulSoup
|
10 |
import validators
|
11 |
from youtube_transcript_api import YouTubeTranscriptApi
|
12 |
+
# from cachetools import TTLCache
|
13 |
+
# import asyncio
|
14 |
+
# import hashlib
|
15 |
+
# import time
|
16 |
|
17 |
|
18 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
|
|
243 |
# raise HTTPException(status_code=500, detail="Internal Server Error")
|
244 |
|
245 |
|
246 |
+
# cache={}
|
247 |
|
248 |
# @app.on_event("startup")
|
249 |
# async def startup_event():
|
|
|
262 |
@app.get("/summary")
|
263 |
async def test(url:str):
|
264 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
265 |
status,content=scrweb(url)
|
266 |
if status==200:
|
267 |
response=genetate_gemini_content(prompt6,content)
|
268 |
print(response)
|
|
|
269 |
return response
|
270 |
else:
|
271 |
return status
|
|
|
344 |
|
345 |
|
346 |
|
|
|
347 |
@app.get("/rm")
|
348 |
async def rm():
|
349 |
global transcript
|