diff --git a/tiktok2bsky.py b/tiktok2bsky.py index 66d6e8b..cb2d86f 100644 --- a/tiktok2bsky.py +++ b/tiktok2bsky.py @@ -789,40 +789,30 @@ def post_video_to_bluesky( # ───────────────────────────────────────────────────────────────────────────── # Caption builder # ───────────────────────────────────────────────────────────────────────────── -def build_caption(video_info: dict, tiktok_handle: str, max_len: int = 290) -> str: +def build_caption(video_info: dict, tiktok_handle: str, max_len: int = 300) -> str: """ Build a Bluesky post caption from video metadata. - Format: - - + The TikTok URL is intentionally omitted — the video is already + embedded in the post, so the URL is redundant. - If description + URL exceeds 290 chars, the description is trimmed at - the last whitespace boundary before the limit to avoid cutting mid-word - or mid-hashtag. + If the description exceeds 300 chars it is trimmed at the last + whitespace boundary before the limit. """ desc = (video_info.get("description") or "").strip() - url = video_info.get("url", "").strip() if not desc: - # No caption available — just post the URL - return url + return "" - # Reserve space for newline + URL - url_block = f"\n{url}" - max_desc = max_len - len(url_block) - - if len(desc) > max_desc: - trimmed = desc[:max_desc - 1] + if len(desc) > max_len: + trimmed = desc[:max_len - 1] cut = trimmed.rfind(" ") # Only use word boundary if it doesn't cut off too much - if cut > max_desc // 2: + if cut > max_len // 2: trimmed = trimmed[:cut] desc = trimmed + "…" - return f"{desc}{url_block}" - - + return desc # ───────────────────────────────────────────────────────────────────────────── # TikTok scraping — Playwright # ─────────────────────────────────────────────────────────────────────────────