Commit 56fe133
Changed files (2)
src
ytdlp
src/ytdlp/download.py
@@ -44,6 +44,7 @@ async def ytdlp_download(
"summary": "summary",
}
"""
+ placeholder = {"video_path": Path("/non-exist"), "audio_path": Path("/non-exist"), "thumb": None}
ytdlp_opts = await get_ytdlp_opts(url=url, platform=platform, proxy=proxy, video=true(kwargs.get("ytdlp_download_video")))
if kwargs.get("show_progress"):
loop = asyncio.get_running_loop()
@@ -58,12 +59,12 @@ async def ytdlp_download(
await modify_progress(del_status=True, **kwargs)
raise ProxyError(ytdlp_error)
await modify_progress(text=ytdlp_error, force_update=True, **kwargs)
- return {}
+ return placeholder
await modify_progress(text=f"⏬正在下载:\n{info['summary']}", force_update=True, **kwargs)
ytdlp_error = await download_video_async(json_path, ytdlp_opts)
if ytdlp_error:
await modify_progress(text=ytdlp_error, force_update=True, **kwargs)
- return {}
+ return placeholder
msg = f"✅下载成功:\n{info['summary']}"
logger.success(f"{msg!r}")
info["thumb"] = find_thumbnail(info["video_path"], info["audio_path"])
src/ytdlp/main.py
@@ -104,7 +104,7 @@ async def preview_ytdlp(
return []
info = await ytdlp_download(url, proxy=proxy, platform=platform, ytdlp_download_video=ytdlp_download_video, **kwargs)
- if not info:
+ if not (info["video_path"].is_file() or info["audio_path"].is_file()):
return []
info |= vinfo # merge video info
captions = await generate_captions(