fix: df3fba7 에 섞여 들어간 옛 파일 되돌림 — 쇼츠 RSS·사주 생년월일 저장·생성 API 클라이언트를 ca6d55f 상태로

This commit is contained in:
minaChoi committed 2026-10-29 09:14:04 +09:00
1 parent cf7c96eaff
commit 051452d3b1
21 files changed
+865 -311

No files matched your search

+6 -7
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 키가 있으면 채널에서, 없으면 설정의 영상 ID 목록으로."""
"""유튜브에서 새로 받아 캐시에 둔다. API 키가 있으면 Data API 로, 없으면 채널 쇼츠 RSS 로."""
try:
async with httpx.AsyncClient(timeout=10) as client:
items = await self._fetch(client)
except (httpx.HTTPError, KeyError, ValueError) as e:
except (httpx.HTTPError, KeyError, ValueError, ET.ParseError) as e:
LOG.error(f"[shorts] fetch: {e}")
return ErrorType.EXTERNAL_API_ERROR, []
try:
@@ -45,7 +45,6 @@ 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)
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]
else:
found = await youtube.feed_shorts(client, settings.youtube_channel_id, MAX_ITEMS)
return [{"id": v["id"], "title": v["title"]} for v in found]