KLypse / app /storage /cache.py
DEVJHAWAR11
Deploy Klypse backend
54bef2f
raw
history blame contribute delete
625 Bytes
import os
from app.config import config
CACHE_DIR = config.CACHE_PATH
os.makedirs(CACHE_DIR, exist_ok=True)
def save_transcript(video_id: str, transcript: str):
"""Save transcript locally."""
file_path = os.path.join(CACHE_DIR, f"{video_id}.txt")
with open(file_path, "w", encoding="utf-8") as f:
f.write(transcript)
def load_transcript(video_id: str) -> str | None:
"""Load transcript if it exists."""
file_path = os.path.join(CACHE_DIR, f"{video_id}.txt")
if os.path.exists(file_path):
with open(file_path, "r", encoding="utf-8") as f:
return f.read()
return None