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:
@@ -62,11 +62,18 @@ 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)
|
||||||
metadata = await adapter.fetch_metadata(
|
if input_data.platform == "zhihu":
|
||||||
input_data.content_id,
|
metadata = await adapter.fetch_metadata(
|
||||||
input_data.content_type
|
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
|
# Save metadata
|
||||||
metadata_filename = adapter.get_output_filename(
|
metadata_filename = adapter.get_output_filename(
|
||||||
@@ -85,10 +92,17 @@ 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"]:
|
||||||
content = await adapter.fetch_content(
|
if input_data.platform == "zhihu":
|
||||||
input_data.content_id,
|
content = await adapter.fetch_content(
|
||||||
input_data.content_type
|
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(
|
content_filename = adapter.get_output_filename(
|
||||||
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,
|
||||||
|
|||||||
Reference in New Issue
Block a user