refactor(podcasts): stream public podcast audio via storage backend

This commit is contained in:
CREDO23 2026-06-10 21:44:57 +02:00
parent 8b52cd0ac9
commit 003d1d2b95
2 changed files with 16 additions and 0 deletions

View file

@ -99,6 +99,17 @@ async def stream_public_podcast(
if not podcast_info:
raise HTTPException(status_code=404, detail="Podcast not found")
storage_key = podcast_info.get("storage_key")
if storage_key:
from app.file_storage.factory import get_storage_backend
return StreamingResponse(
get_storage_backend().open_stream(storage_key),
media_type="audio/mpeg",
headers={"Accept-Ranges": "bytes"},
)
# Legacy fallback for snapshots taken before the storage migration.
file_path = podcast_info.get("file_path")
if not file_path or not os.path.isfile(file_path):

View file

@ -337,6 +337,9 @@ async def _get_podcast_for_snapshot(
"original_id": podcast.id,
"title": podcast.title,
"transcript": podcast.podcast_transcript,
"storage_backend": podcast.storage_backend,
"storage_key": podcast.storage_key,
# Legacy fallback for rows rendered before the storage migration.
"file_path": podcast.file_location,
}
@ -717,6 +720,8 @@ async def clone_from_snapshot(
new_podcast = Podcast(
title=podcast_info.get("title", "Cloned Podcast"),
podcast_transcript=podcast_info.get("transcript"),
storage_backend=podcast_info.get("storage_backend"),
storage_key=podcast_info.get("storage_key"),
file_location=podcast_info.get("file_path"),
status=PodcastStatus.READY,
search_space_id=target_search_space_id,