#2127·NewsBlur

Mastodon RSS: 图像 alt 文本取代真实的帖子文本,而不是与之并列显示

作者: rdtbk创建于 2026年8月29日更新于 2026年8月29日

utils/story_functions.pypre_process_story() (~行 272–292):

python
summary = entry.get("summary") or ""
content = ""
...
if entry.get("content"):
    html_items = [c for c in entry["content"] if c.get("type") == "text/html"]
    chosen = (
        max(html_items, key=lambda c: len(c.get("value", "") or ""))
        if html_items
        else max(entry["content"], key=lambda c: len(c.get("value", "") or ""))
    )
    content = chosen.get("value", "") or ""
if len(content) > len(summary):
    entry["story_content"] = content.strip()
else:
    entry["story_content"] = summary.strip()

feedparser 将 RSS 的 <media:description> 合并到 entry["content"] 中,作为一个单独的 text/plain 项(已经通过一个针对不同 feed 形状的测试来覆盖 - apps/rss_feeds/test_rss_feeds.pyTest_PreProcessStoryContentSelection.test_picks_html_content_over_plain_media_description,该测试断言当 feed 同时包含 content:encodedmedia:description 时,entry.get("content") 具有 2 个项)。该测试的修复正确地优先选择 text/html(真实的 content:encoded 正文)而不是纯文本的 media:description,如果两者都存在。但是 Mastodon toot 中 没有 content:encoded - 真实的文本只存在于 <description>entry.summary 中。因此,entry["content"] 中只包含一个项:media:description 的 alt-text。没有 html_items,代码回退到 max(entry["content"], ...),选择该 alt-text 项,并且由于它几乎总是比短/空 caption 长,因此它覆盖了 entry.summary 作为故事正文。

内容来源: samuelclay/NewsBlur