Commit 7808832
Changed files (1)
src
subtitles
src/subtitles/base.py
@@ -9,7 +9,7 @@ from pyrogram.client import Client
from pyrogram.types import Message
from youtube_transcript_api import YouTubeTranscriptApi # type: ignore
-from config import API, PREFIX, PROXY, READING_SPEED, TOKEN, TZ
+from config import API, PREFIX, PROXY, READING_SPEED, TOKEN, TZ, cache
from messages.parser import parse_msg
from messages.utils import startswith_prefix
from networking import hx_req, match_social_media_link
@@ -47,6 +47,7 @@ async def match_url(client: Client, message: Message) -> str:
return ""
+@cache.memoize(ttl=120)
async def fetch_subtitle(url: str, provider: str) -> dict:
"""Fetch subtitles from YouTube."""
succ = False