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
+35 -9
View File
@@ -62,11 +62,18 @@ class DownloadProcessor(BaseProcessor):
return self._record_failure(str(e))
try:
# Fetch metadata
metadata = await adapter.fetch_metadata(
input_data.content_id,
input_data.content_type
)
# 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(
input_data.content_id,
input_data.content_type
)
# Save metadata
metadata_filename = adapter.get_output_filename(
@@ -85,10 +92,17 @@ class DownloadProcessor(BaseProcessor):
# Fetch content (for text-based content)
content_file = ""
if input_data.content_type in ["article", "answer", "zhuanlan"]:
content = await adapter.fetch_content(
input_data.content_id,
input_data.content_type
)
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(
input_data.content_id,
input_data.content_type
)
content_filename = adapter.get_output_filename(
input_data.content_id,
input_data.content_type,
@@ -98,6 +112,18 @@ class DownloadProcessor(BaseProcessor):
self._save_content(content, 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
result = DownloadOutput(
success=True,