Commit cbf318f
Changed files (1)
src
preview
src/preview/ytdlp.py
@@ -39,6 +39,8 @@ async def preview_ytdlp(
ytdlp_audio_only: bool = False,
ytdlp_send_video: bool = True,
ytdlp_send_audio: bool = False,
+ bilibili_comments: bool = True,
+ youtube_comments: bool = True,
proxy: str | None = None,
**kwargs,
):
@@ -52,6 +54,8 @@ async def preview_ytdlp(
ytdlp_audio_only (bool, optional): Download audio only. Defaults to True.
ytdlp_send_video (bool, optional): Send video. Defaults to True.
ytdlp_send_audio (bool, optional): Send audio. Defaults to False.
+ bilibili_comments (bool, optional): Get bilibili comments. Defaults to True.
+ youtube_comments (bool, optional): Get youtube comments. Defaults to True.
proxy (str, optional): Proxy to use. Defaults to None.
"""
logger.trace(f"url: {url} kwargs: {kwargs}")
@@ -175,7 +179,13 @@ async def preview_ytdlp(
warnings.simplefilter("ignore", MarkupResemblesLocatorWarning)
soup = BeautifulSoup(desc, "html.parser")
texts += f"\n{soup_to_text(soup)}"
- comments = await get_bilibili_comments(kwargs.get("bvid")) if platform == "bilibili" else await get_youtube_comments(kwargs.get("vid"))
+ # comments
+ comments = []
+ if bilibili_comments and platform == "bilibili":
+ comments = await get_bilibili_comments(kwargs.get("bvid"))
+ if youtube_comments and platform == "youtube":
+ await get_youtube_comments(kwargs.get("vid"))
+
for comment in comments:
if len(f"{texts}{comment}") < CAPTION_LENGTH:
texts += comment