v0.1.2: 검색 속도 개선, 인피니티 스크롤 최적화, 미니 플레이어 추가

This commit is contained in:
2026-01-24 22:22:02 +09:00
parent b27bf655f2
commit 901fcd0541
15 changed files with 893 additions and 37 deletions

View File

@@ -197,16 +197,34 @@ class MyYoutubeDL:
"""미리보기용 직접 재생 가능한 URL 추출"""
youtube_dl = __import__(youtube_dl_package)
try:
# 미리보기를 위해 포맷 필터링 (mp4, 비디오+오디오 권장)
# 미리보기를 위해 다양한 포맷 시도 (mp4, hls 등)
ydl_opts: Dict[str, Any] = {
"format": "best[ext=mp4]/best",
"format": "best[ext=mp4]/bestvideo[ext=mp4]+bestaudio[ext=m4a]/best",
"logger": MyLogger(),
"nocheckcertificate": True,
"quiet": True,
"js_runtimes": {"node": {"path": "/Users/yommi/.local/state/fnm_multishells/53824_1769161399333/bin/node"}},
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
info: Dict[str, Any] = ydl.extract_info(url, download=False)
return info.get("url")
# 1. HLS 매니페스트 우선 (가장 안정적으로 오디오+비디오 제공)
if info.get("manifest_url"):
return info["manifest_url"]
# 2. 직접 URL (ydl_opts에서 지정한 best[ext=mp4] 결과)
if info.get("url"):
return info["url"]
# 3. 포맷 목록에서 적절한 것 찾기
formats = info.get("formats", [])
# 오디오와 비디오가 모두 있는 포맷 찾기
combined_formats = [f for f in formats if f.get("vcodec") != "none" and f.get("acodec") != "none"]
if combined_formats:
# 가장 좋은 화질의 결합 포맷 선택
return combined_formats[-1].get("url")
return None
except Exception as error:
logger.error(f"미리보기 URL 추출 중 예외 발생: {error}")
return None
@@ -225,17 +243,24 @@ class MyYoutubeDL:
proxy: Optional[str] = None,
cookiefile: Optional[str] = None,
http_headers: Optional[Dict[str, str]] = None,
cookiesfrombrowser: Optional[str] = None
cookiesfrombrowser: Optional[str] = None,
**extra_opts
) -> Optional[Dict[str, Any]]:
"""비디오 메타데이터 정보 추출"""
youtube_dl = __import__(youtube_dl_package)
try:
ydl_opts: Dict[str, Any] = {
"extract_flat": "in_playlist",
"logger": MyLogger(),
"nocheckcertificate": True,
"quiet": True,
# JS 런타임 수동 지정 (유저 시스템 환경 반영)
"js_runtimes": {"node": {"path": "/Users/yommi/.local/state/fnm_multishells/53824_1769161399333/bin/node"}},
}
# 기본값으로 extract_flat 적용 (명시적으로 override 가능)
if "extract_flat" not in extra_opts:
ydl_opts["extract_flat"] = True # True = 모든 추출기에 적용
if proxy:
ydl_opts["proxy"] = proxy
if cookiefile:
@@ -244,6 +269,9 @@ class MyYoutubeDL:
ydl_opts["http_headers"] = http_headers
if cookiesfrombrowser:
ydl_opts["cookiesfrombrowser"] = (cookiesfrombrowser, None, None, None)
# 추가 옵션 반영 (playliststart, playlistend 등)
ydl_opts.update(extra_opts)
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
info: Dict[str, Any] = ydl.extract_info(url, download=False)