Fix: [2.0.10] 라이브/쇼츠 스킵 및 네트워크 타임아웃 설정
All checks were successful
news-summary-bot-cicd / build_push_deploy (push) Successful in 18m49s
All checks were successful
news-summary-bot-cicd / build_push_deploy (push) Successful in 18m49s
- 라이브/쇼츠 영상 감지 시 에러 대신 스킵 처리 - yt-dlp socket_timeout, httpx timeout, Discord webhook timeout 30초로 설정 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -8,8 +8,14 @@ import yt_dlp
|
||||
COOKIES_SRC = "/app/cookies.txt"
|
||||
|
||||
|
||||
class SkipVideo(Exception):
|
||||
"""라이브/쇼츠 등 요약 대상이 아닌 영상."""
|
||||
|
||||
|
||||
def extract_video_id(url: str) -> str:
|
||||
"""YouTube URL에서 video ID 추출."""
|
||||
if "/shorts/" in url:
|
||||
raise SkipVideo("쇼츠 영상은 요약 대상이 아닙니다")
|
||||
if "youtu.be/" in url:
|
||||
return url.split("youtu.be/")[1].split("?")[0]
|
||||
if "v=" in url:
|
||||
@@ -25,6 +31,7 @@ def fetch_transcript(video_id: str) -> str:
|
||||
"skip_download": True,
|
||||
"quiet": True,
|
||||
"no_warnings": True,
|
||||
"socket_timeout": 30,
|
||||
}
|
||||
|
||||
if os.path.isfile(COOKIES_SRC):
|
||||
@@ -39,6 +46,9 @@ def fetch_transcript(video_id: str) -> str:
|
||||
if "cookiefile" in ydl_opts:
|
||||
os.unlink(ydl_opts["cookiefile"])
|
||||
|
||||
if info.get("is_live") or info.get("live_status") in ("is_live", "is_upcoming"):
|
||||
raise SkipVideo("라이브/예정 영상은 요약 대상이 아닙니다")
|
||||
|
||||
subs = info.get("automatic_captions", {})
|
||||
lang = "ko" if "ko" in subs else "en" if "en" in subs else None
|
||||
if not lang:
|
||||
@@ -53,7 +63,7 @@ def fetch_transcript(video_id: str) -> str:
|
||||
if not sub_url:
|
||||
raise ValueError(f"json3 자막 포맷을 찾을 수 없습니다: {video_id}")
|
||||
|
||||
resp = httpx.get(sub_url)
|
||||
resp = httpx.get(sub_url, timeout=30.0)
|
||||
resp.raise_for_status()
|
||||
data = resp.json()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user