응원가 영구 보존·종료 경기 노출 — 음원 DB 저장 + 경기별 조회 API
- Suno CDN 임시 URL 만료 대비: 완성 곡 첫 트랙을 워커가 다운로드해
song_audio(bytea)로 보존하고 audioUrl을 /api/songs/audio/{id}/{idx}로 재작성
(틱당 5곡, 실패 3회 상한 — 기존 곡도 자동 백필)
- GET /api/songs/match/{match_id} 추가 — 날짜 무관 조회로 종료된 경기
상세에서도 '응원가 듣기' 버튼 노출
- 프론트 getTeamSongTracks를 오늘 전체 캐시 → 경기별 조회·캐시로 전환
- 음원 서빙은 Range(206) 지원, immutable 캐시 + task_id 캐시버스터
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bc333d64f4
commit
fdb04a2ccc
5 files changed
+186
-26
No files matched your search
+29
-1
@@ -19,6 +19,7 @@ from sqlalchemy import (
|
||||
DateTime,
|
||||
ForeignKey,
|
||||
Integer,
|
||||
LargeBinary,
|
||||
String,
|
||||
UniqueConstraint,
|
||||
func,
|
||||
@@ -302,7 +303,8 @@ class Song(Base):
|
||||
"""오늘의 응원가 — 경기×팀 단위 Suno 생성 트랙.
|
||||
|
||||
가사·스타일은 LLM(경기 맥락 주입)이 쓰고, 음원은 Suno(sunoapi.org)가 생성.
|
||||
audio/image URL 은 제공자 CDN 을 그대로 사용(당일 소비 콘텐츠라 다운로드 불필요).
|
||||
Suno CDN URL 은 임시라 완성 후 워커가 음원을 SongAudio 로 내려받아 보존하고
|
||||
tracks 의 audioUrl 을 자체 서빙 경로(/api/songs/audio/...)로 바꾼다.
|
||||
"""
|
||||
|
||||
__tablename__ = "songs"
|
||||
@@ -341,6 +343,32 @@ class Song(Base):
|
||||
)
|
||||
|
||||
|
||||
class SongAudio(Base):
|
||||
"""응원가 음원 원본 — Suno CDN 임시 URL 만료 대비 DB 보존.
|
||||
|
||||
노출 트랙(첫 트랙)만 저장한다. 업그레이드(라인업 반영 재생성) 시
|
||||
같은 (song_id, track_idx) 행을 새 음원으로 교체.
|
||||
"""
|
||||
|
||||
__tablename__ = "song_audio"
|
||||
__table_args__ = (
|
||||
UniqueConstraint("song_id", "track_idx", name="uq_song_audio_track"),
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
||||
song_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("songs.id", ondelete="CASCADE"), index=True
|
||||
)
|
||||
track_idx: Mapped[int] = mapped_column(Integer, default=0)
|
||||
mime: Mapped[str] = mapped_column(String, default="audio/mpeg")
|
||||
size: Mapped[int] = mapped_column(Integer, default=0)
|
||||
data: Mapped[bytes] = mapped_column(LargeBinary)
|
||||
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True), server_default=func.now()
|
||||
)
|
||||
|
||||
|
||||
class DataCache(Base):
|
||||
"""야구(KBO/MLB) 부가 데이터 캐시 — 프리뷰·순위, API 응답·AI 프롬프트 조립용.
|
||||
|
||||
|
||||
Reference in new issue
Block a user