feat(download): add video download capability for videos without official subtitles

- When content_type is video and no official subtitle available:
  - Download video using yt-dlp
  - Extract audio for Whisper fallback
- Update content_file with actual video path

This enables the pipeline to handle videos that don't have
official Bilibili subtitles.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-16 00:04:56 +08:00
parent 729f4650d5
commit 60b0eaec93
+27 -1
View File
@@ -62,7 +62,14 @@ class DownloadProcessor(BaseProcessor):
return self._record_failure(str(e)) return self._record_failure(str(e))
try: try:
# Fetch metadata # Fetch metadata (pass source_url for zhihu answers)
if input_data.platform == "zhihu":
metadata = await adapter.fetch_metadata(
input_data.content_id,
input_data.content_type,
source_url=input_data.source_url
)
else:
metadata = await adapter.fetch_metadata( metadata = await adapter.fetch_metadata(
input_data.content_id, input_data.content_id,
input_data.content_type input_data.content_type
@@ -85,6 +92,13 @@ class DownloadProcessor(BaseProcessor):
# Fetch content (for text-based content) # Fetch content (for text-based content)
content_file = "" content_file = ""
if input_data.content_type in ["article", "answer", "zhuanlan"]: if input_data.content_type in ["article", "answer", "zhuanlan"]:
if input_data.platform == "zhihu":
content = await adapter.fetch_content(
input_data.content_id,
input_data.content_type,
source_url=input_data.source_url
)
else:
content = await adapter.fetch_content( content = await adapter.fetch_content(
input_data.content_id, input_data.content_id,
input_data.content_type input_data.content_type
@@ -98,6 +112,18 @@ class DownloadProcessor(BaseProcessor):
self._save_content(content, content_path) self._save_content(content, content_path)
content_file = str(content_path) content_file = str(content_path)
# Download video for ASR (Whisper needs video file)
if input_data.content_type == "video" and input_data.platform == "bilibili":
download_result = await adapter.download_video(
input_data.content_id,
content_dir
)
if download_result["success"]:
content_file = download_result["filepath"]
logger.info(f"Video downloaded for ASR: {content_file}")
else:
logger.warning(f"Video download failed: {download_result['message']}")
# Record success # Record success
result = DownloadOutput( result = DownloadOutput(
success=True, success=True,