removed url
This commit is contained in:
@@ -789,40 +789,30 @@ def post_video_to_bluesky(
|
|||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
# Caption builder
|
# 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.
|
Build a Bluesky post caption from video metadata.
|
||||||
|
|
||||||
Format:
|
The TikTok URL is intentionally omitted — the video is already
|
||||||
<description>
|
embedded in the post, so the URL is redundant.
|
||||||
<tiktok_url>
|
|
||||||
|
|
||||||
If description + URL exceeds 290 chars, the description is trimmed at
|
If the description exceeds 300 chars it is trimmed at the last
|
||||||
the last whitespace boundary before the limit to avoid cutting mid-word
|
whitespace boundary before the limit.
|
||||||
or mid-hashtag.
|
|
||||||
"""
|
"""
|
||||||
desc = (video_info.get("description") or "").strip()
|
desc = (video_info.get("description") or "").strip()
|
||||||
url = video_info.get("url", "").strip()
|
|
||||||
|
|
||||||
if not desc:
|
if not desc:
|
||||||
# No caption available — just post the URL
|
return ""
|
||||||
return url
|
|
||||||
|
|
||||||
# Reserve space for newline + URL
|
if len(desc) > max_len:
|
||||||
url_block = f"\n{url}"
|
trimmed = desc[:max_len - 1]
|
||||||
max_desc = max_len - len(url_block)
|
|
||||||
|
|
||||||
if len(desc) > max_desc:
|
|
||||||
trimmed = desc[:max_desc - 1]
|
|
||||||
cut = trimmed.rfind(" ")
|
cut = trimmed.rfind(" ")
|
||||||
# Only use word boundary if it doesn't cut off too much
|
# 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]
|
trimmed = trimmed[:cut]
|
||||||
desc = trimmed + "…"
|
desc = trimmed + "…"
|
||||||
|
|
||||||
return f"{desc}{url_block}"
|
return desc
|
||||||
|
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
# TikTok scraping — Playwright
|
# TikTok scraping — Playwright
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user