Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions backend/app/downloaders/bilibili_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def download(
video_url: str,
output_dir: Union[str, None] = None,
quality: DownloadQuality = "fast",
need_video:Optional[bool]=False
need_video:Optional[bool]=False,
skip_download: bool = False
) -> AudioDownloadResult:
if output_dir is None:
output_dir = get_data_dir()
Expand Down Expand Up @@ -81,12 +82,13 @@ def download(
ydl_opts['cookiefile'] = self._cookiefile

with yt_dlp.YoutubeDL(ydl_opts) as ydl:
info = ydl.extract_info(video_url, download=True)
# skip_download=True 时只提取元信息(标题/时长/封面),不下载音视频文件
info = ydl.extract_info(video_url, download=not skip_download)
video_id = info.get("id")
title = info.get("title")
duration = info.get("duration", 0)
cover_url = info.get("thumbnail")
audio_path = os.path.join(output_dir, f"{video_id}.mp3")
audio_path = os.path.join(output_dir, f"{video_id}.mp3") if not skip_download else None

return AudioDownloadResult(
file_path=audio_path,
Expand Down