feat: 구름 합치기 GA4 이벤트 — game_start(첫 그림)·game_round(라운드 깸)·game_over(넘침)

This commit is contained in:
minaChoi committed 2026-10-29 09:04:11 +09:00
1 parent 63b4fa74fe
commit df3fba720c
26 files changed
+330 -900

No files matched your search

+7 -6
View File
@@ -1,5 +1,5 @@
import asyncio
import json
import xml.etree.ElementTree as ET
import httpx
from redis.exceptions import RedisError
@@ -29,11 +29,11 @@ class ShortsService:
return await self.refresh()
async def refresh(self) -> tuple[ErrorType, list[dict]]:
"""유튜브에서 새로 받아 캐시에 둔다. API 키가 있으면 Data API 로, 없으면 채널 쇼츠 RSS 로."""
"""유튜브에서 새로 받아 캐시에 둔다. API 키가 있으면 채널에서, 없으면 설정의 영상 ID 목록으로."""
try:
async with httpx.AsyncClient(timeout=10) as client:
items = await self._fetch(client)
except (httpx.HTTPError, KeyError, ValueError, ET.ParseError) as e:
except (httpx.HTTPError, KeyError, ValueError) as e:
LOG.error(f"[shorts] fetch: {e}")
return ErrorType.EXTERNAL_API_ERROR, []
try:
@@ -45,6 +45,7 @@ class ShortsService:
async def _fetch(self, client: httpx.AsyncClient) -> list[dict]:
if settings.youtube_api_key:
found = await youtube.channel_shorts(client, settings.youtube_api_key, settings.youtube_channel_id, MAX_ITEMS)
else:
found = await youtube.feed_shorts(client, settings.youtube_channel_id, MAX_ITEMS)
return [{"id": v["id"], "title": v["title"]} for v in found]
return [{"id": v["id"], "title": v["title"]} for v in found]
ids = [i.strip() for i in settings.youtube_shorts.split(",") if i.strip()][:MAX_ITEMS]
titles = await asyncio.gather(*(youtube.video_title(client, i) for i in ids))
return [{"id": i, "title": t} for i, t in zip(ids, titles) if t]