Files
breakpilot-lehrer/backend-lehrer/recording/helpers.py
Benjamin Admin dde45b29db
Some checks failed
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-school (push) Successful in 27s
CI / test-go-edu-search (push) Successful in 40s
CI / test-python-klausur (push) Failing after 2m30s
CI / test-python-agent-core (push) Successful in 28s
CI / test-nodejs-website (push) Successful in 20s
Restructure: Move 43 files into 8 domain packages (backend-lehrer)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-25 22:32:45 +02:00

58 lines
1.5 KiB
Python

"""
Recording API - In-Memory Storage & Helpers.
Shared state and utility functions for recording endpoints.
"""
import uuid
from datetime import datetime
from typing import Optional
# ==========================================
# IN-MEMORY STORAGE (Dev Mode)
# ==========================================
# In production, these would be database queries
_recordings_store: dict = {}
_transcriptions_store: dict = {}
_audit_log: list = []
_minutes_store: dict = {}
def log_audit(
action: str,
recording_id: Optional[str] = None,
transcription_id: Optional[str] = None,
user_id: Optional[str] = None,
metadata: Optional[dict] = None
):
"""Log audit event for DSGVO compliance."""
_audit_log.append({
"id": str(uuid.uuid4()),
"recording_id": recording_id,
"transcription_id": transcription_id,
"user_id": user_id,
"action": action,
"metadata": metadata or {},
"created_at": datetime.utcnow().isoformat()
})
def format_vtt_time(ms: int) -> str:
"""Format milliseconds to VTT timestamp (HH:MM:SS.mmm)."""
hours = ms // 3600000
minutes = (ms % 3600000) // 60000
seconds = (ms % 60000) // 1000
millis = ms % 1000
return f"{hours:02d}:{minutes:02d}:{seconds:02d}.{millis:03d}"
def format_srt_time(ms: int) -> str:
"""Format milliseconds to SRT timestamp (HH:MM:SS,mmm)."""
hours = ms // 3600000
minutes = (ms % 3600000) // 60000
seconds = (ms % 60000) // 1000
millis = ms % 1000
return f"{hours:02d}:{minutes:02d}:{seconds:02d},{millis:03d}"