Fix dead oversized-video link and stop exposing the platform limit to readers
build_oversized_video_note linked to the video's own VK page (with an access_key suffix), which 404s for viewers without a VK session - reported as "такой страницы нет" on a real post. Point at the wall post instead (vk_url), same as build_media_unavailable_note already does, since that always resolves. Also dropped "Видео слишком большое для платформы" from the visible text - subscribers don't need to know MAX has a 250MB cap, that's an internal implementation detail, not something worth surfacing in a public post. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -305,7 +305,7 @@ class MAXPoster:
|
||||
)
|
||||
|
||||
note = build_media_unavailable_note(link_only_media or [], parse_mode="html", vk_url=vk_url)
|
||||
video_note = build_oversized_video_note(oversized_videos or [], parse_mode="html")
|
||||
video_note = build_oversized_video_note(oversized_videos or [], parse_mode="html", vk_url=vk_url)
|
||||
for extra in (note, video_note):
|
||||
if extra:
|
||||
formatted_text = f"{formatted_text}\n\n{extra}" if formatted_text else extra
|
||||
|
||||
+19
-15
@@ -172,27 +172,31 @@ def build_media_unavailable_note(
|
||||
return header + "\n" + "\n".join(lines)
|
||||
|
||||
|
||||
def build_oversized_video_note(items: list, parse_mode: str = "html") -> str:
|
||||
def build_oversized_video_note(
|
||||
items: list, parse_mode: str = "html", vk_url: Optional[str] = None
|
||||
) -> str:
|
||||
"""Like build_media_unavailable_note, but for videos that were deliberately
|
||||
skipped for exceeding a platform's size limit (e.g. MAX's 250MB video cap) -
|
||||
friendlier tone since this isn't a failure, just a known platform limit."""
|
||||
skipped for exceeding a platform's size limit (e.g. MAX's 250MB video cap).
|
||||
Points at the wall post (vk_url), not the video's own page - VK's direct
|
||||
video URLs can 404 for viewers without a session, while the post always
|
||||
resolves. Wording doesn't mention the platform limit: that's an internal
|
||||
reason for readers, not something worth surfacing to subscribers."""
|
||||
if not items:
|
||||
return ""
|
||||
lines = []
|
||||
for item in items:
|
||||
url = str(getattr(item, "original_url", "") or "").strip()
|
||||
if not url:
|
||||
continue
|
||||
if parse_mode == "html":
|
||||
lines.append(f'- <a href="{html.escape(url, quote=True)}">видео по ссылке</a>')
|
||||
else:
|
||||
lines.append(f"- видео по ссылке: {url}")
|
||||
if not lines:
|
||||
target = vk_url or next(
|
||||
(str(getattr(item, "original_url", "") or "").strip() for item in items if getattr(item, "original_url", None)),
|
||||
"",
|
||||
)
|
||||
if not target:
|
||||
return ""
|
||||
header = "Видео слишком большое для платформы, посмотреть можно здесь:"
|
||||
if parse_mode == "html":
|
||||
line = f'- <a href="{html.escape(target, quote=True)}">Смотреть видео в VK</a>'
|
||||
else:
|
||||
line = f"- Смотреть видео в VK: {target}"
|
||||
header = "Видео к этому посту:"
|
||||
if parse_mode == "html":
|
||||
header = f"<i>{html.escape(header)}</i>"
|
||||
return header + "\n" + "\n".join(lines)
|
||||
return header + "\n" + line
|
||||
|
||||
|
||||
def format_post_text(
|
||||
|
||||
Reference in New Issue
Block a user