fix: 공유 썸네일 크기 조절

This commit is contained in:
skkim committed 2026-08-20 14:42:58 +09:00
1 parent a727d4f1ac
commit e8a268e7b4
6 files changed
+374 -47

No files matched your search

+46 -1
View File
@@ -15,7 +15,15 @@ Video API Router
from typing import Literal
from fastapi import APIRouter, BackgroundTasks, Depends, HTTPException, Query, Request
from fastapi import (
APIRouter,
BackgroundTasks,
Depends,
HTTPException,
Query,
Request,
Response,
)
from fastapi.responses import HTMLResponse
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
@@ -61,6 +69,7 @@ from app.video.worker.video_task import (
_fail_and_refund,
download_and_upload_video_to_blob,
)
from app.video.services.share_image import build_og_card
from app.video.services.share_page import (
build_video_share_html,
get_video_share_data,
@@ -1131,6 +1140,42 @@ async def get_video_share_page(
)
@router.get(
"/share/{video_id}/og.jpg",
summary="영상 공유 카드 이미지",
description=(
"포스터를 1200x630 카드로 합성해 반환합니다. 세로 포스터는 좌우 여백을 "
"블러 배경으로 채워 잘리지 않게 합니다."
),
response_class=Response,
responses={
200: {"content": {"image/jpeg": {}}, "description": "공유 카드 JPEG 반환"},
404: {"description": "공유 가능한 완료 영상을 찾을 수 없음"},
},
)
async def get_video_share_og_image(
video_id: int,
session: AsyncSession = Depends(get_session),
) -> Response:
"""크롤러가 링크 카드에 쓸 규격 이미지를 반환합니다."""
share_data = await get_video_share_data(session, video_id)
if share_data is None:
raise HTTPException(status_code=404, detail="공유 가능한 영상을 찾을 수 없습니다.")
card = await build_og_card(
share_data.poster_url,
prj_settings.SHARE_DEFAULT_IMAGE_URL,
)
return Response(
content=card,
media_type="image/jpeg",
headers={
"Cache-Control": "public, max-age=86400",
"X-Content-Type-Options": "nosniff",
},
)
@router.get(
"/{video_id}",
summary="단일 영상 상세 조회",