YouTube URI无法在onebox时渲染缩略图

  1. https://youtube.com/shorts/Cs3sTnLO6EE

  2. https://www.youtube.com/watch?v=Cs3sTnLO6EE&lc=Ugyi1VtrCVd2POTc82N4AaABAg#:~:text=A%20Screencast%20Of%20LinkedIn%20Persona%20Verification%20Failure

…变成一个透明的盒子:

DOM显示:


<img src="" width="480" height="360" title=" - YouTube" style="aspect-ratio: 480 / 360;">

但是,发布时它们会渲染:

1 个赞

确认,抓得好,我将暂时为此添加一个 pr-welcome 并给团队留个便条进行分类。

1 个赞

这是一个有趣的问题,我可以在 Meta 上重现 OP 中链接的问题,但在本地和我们的内部 Discourse 网站上,它们可以正常获取和呈现:

@rokejulianlockhart 这些链接在你自己的网站上无法正常呈现,还是仅仅在这里 Meta 上无法正常呈现?

1 个赞

@martin,其他人也遇到了类似问题:

非短链接

使用 https://www.youtube.com/watch?v=Cs3sTnLO6EE&lc=Ugyi1VtrCVd2POTc82N4AaABAg#:~:text=A%20Screencast%20Of%20LinkedIn%20Persona%20Verification%20Failure,在以下位置可以复现:

  1. discuss.kde.org/new-topic

    [1]

  2. forum.fairphone.com/new-topic

    [1:1]

然而,在 discussion.fedoraproject.org 上,它能够正常显示:

[1:2]

短链接

\u003cdetails open\u003e

使用 https://youtube.com/shorts/Cs3sTnLO6EE,可以复现以下问题:

…在以下位置可以复现:

  1. discuss.kde.org/new-topic

    [1:3]

  2. forum.fairphone.com/new-topic

    [1:4]

然而,和之前一样,在 discussion.fedoraproject.org 上,它能够正常显示:

[1:5]

\u003c/details\u003e

Fedora 做了什么,让它们能正确显示?


  1. bugs.kde.org/show_bug.cgi?id=511477#c1 ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎

2 个赞

此问题是否已解决?我为我的面板上当前遇到的类似问题开了一个主题。

@hameedacpa,这与那个完全无关,因为这是关于预览器的。此外,您可以通过简单地使用预览器来确认它尚未得到修复。我建议您安装一个翻译器。

1 个赞

我发现了这个主题,其中包含我遇到的部分问题

1 个赞

@hameedacpa,这很相似,尽管我怀疑它是否等同。无效缩略图图标的存在似乎证明了这一点,以及<img>的不同纵横比。如果您将这些详细信息放入387672/1,它们将在那里有用。如果它们仅仅是浏览器引起的差异,它将被分类为该问题的部分重复。

话虽如此,请在引用的线程中包含您的浏览器版本、Discourse 版本以及渲染内容的实际标记。目前,除了屏幕截图之外,它什么都没有;您需要付出努力才能获得无偿帮助。

我们的 Onebox 流出现了一些问题,我认为与重定向/FinalDestination 有关。如果我像这样使用 curl

curl -L https://youtube.com/shorts/Cs3sTnLO6EE

我能在响应中找到 title 和其他 meta 标签:

curl -L https://youtube.com/shorts/Cs3sTnLO6EE | htmlq 'head > meta'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0   0     0   0     0     0     0  --:--:-- --:--:-- --:--:--     0
100 947221   0 947221   0     0 406174     0  --:--:--  0:00:02 --:--:-- 504109
<meta content="IE=edge" http-equiv="X-UA-Compatible">
<meta content="ApvK67ociHgr2egd6c2ZjrfPuRs8BHcvSggogIOPQNH7GJ3cVlyJ1NOq/COCdj0+zxskqHt9HgLLETc8qqD+vwsAAABteyJvcmlnaW4iOiJodHRwczovL3lvdXR1YmUuY29tOjQ0MyIsImZlYXR1cmUiOiJQcml2YWN5U2FuZGJveEFkc0FQSXMiLCJleHBpcnkiOjE2OTUxNjc5OTksImlzU3ViZG9tYWluIjp0cnVlfQ==" http-equiv="origin-trial">
<meta content="rgba(255, 255, 255, 0.98)" name="theme-color">
<meta content="A Screencast Of LinkedIn Persona Verification Failure" name="title">
<meta content="For https://www.linkedin.com/help/linkedin/cases/73171318#:~:text=Thanks%20for%20contacting%20us%20about,to%20troubleshoot%20any%20additional%20causes." name="description">
...
 curl -L https://youtube.com/shorts/Cs3sTnLO6EE | htmlq 'head > title'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0   0     0   0     0     0     0  --:--:-- --:--:-- --:--:--     0
100 992110   0 992110   0     0 445530     0  --:--:--  0:00:02 --:--:-- 739941
<title>A Screencast Of LinkedIn Persona Verification Failure - YouTube</title>

然而,当通过我们的 oneboxer 代码获取响应时,这些是 <head> 中除(script + style)之外我们获得的唯一标签:

uri = FinalDestination.new("https://youtube.com/shorts/Cs3sTnLO6EE", Oneboxer.get_final_destination_options("https://youtube.com/shorts/Cs3sTnLO6EE")).resolve
doc2 = Onebox::Helpers.fetch_response(uri)
Nokogiri.HTML(doc2).css("head").children.each do |headel|
  next if headel.name == "script" || headel.name == "style"
  puts headel.to_s
end; nil;

<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="origin-trial" content="ApvK67ociHgr2egd6c2ZjrfPuRs8BHcvSggogIOPQNH7GJ3cVlyJ1NOq/COCdj0+zxskqHt9HgLLETc8qqD+vwsAAABteyJvcmlnaW4iOiJodHRwczovL3lvdXR1YmUuY29tOjQ0MyIsImZlYXR1cmUiOiJQcml2YWN5U2FuZGJveEFkc0FQSXMiLCJleHBpcnkiOjE2OTUxNjc5OTksImlzU3ViZG9tYWluIjp0cnVlfQ==">
<link rel="shortcut icon" href="https://www.youtube.com/s/desktop/ace6261e/img/favicon.ico" type="image/x-icon">
<link rel="icon" href="https://www.youtube.com/s/desktop/ace6261e/img/favicon_32x32.png" sizes="32x32">
<link rel="icon" href="https://www.youtube.com/s/desktop/ace6261e/img/favicon_48x48.png" sizes="48x48">
<link rel="icon" href="https://www.youtube.com/s/desktop/ace6261e/img/favicon_96x96.png" sizes="96x96">
<link rel="icon" href="https://www.youtube.com/s/desktop/ace6261e/img/favicon_144x144.png" sizes="144x144">
<link rel="stylesheet" href="//fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&amp;family=YouTube+Sans:wght@300..900&amp;display=swap" nonce="kFtYVVw9wWKkoPdOJkO9xQ">
<link rel="stylesheet" href="/s/player/65578ad1/www-player.css" nonce="kFtYVVw9wWKkoPdOJkO9xQ">
<link rel="stylesheet" href="https://www.youtube.com/s/desktop/ace6261e/cssbin/www-main-desktop-player-skeleton.css" nonce="kFtYVVw9wWKkoPdOJkO9xQ">
<link rel="stylesheet" href="https://www.youtube.com/s/desktop/ace6261e/cssbin/www-onepick.css" nonce="kFtYVVw9wWKkoPdOJkO9xQ">
<link rel="stylesheet" href="https://www.youtube.com/s/_/ytmainappweb/_/ss/k=ytmainappweb.kevlar_base.dsnGl9m3_bM.L.X.O/am=AAAgAAgk/d=0/rs=AGKMywEVyAGSU99VwQpoLFio5FrCvZ1WpA" nonce="kFtYVVw9wWKkoPdOJkO9xQ">
<meta name="theme-color" content="rgba(255, 255, 255, 0.98)">
<link rel="search" type="application/opensearchdescription+xml" href="https://www.youtube.com/opensearch?locale=en_US" title="YouTube">
<link rel="manifest" href="/manifest.webmanifest" crossorigin="use-credentials">
<link rel="canonical" href="undefined">
<link rel="alternate" media="handheld" href="https://m.youtube.com/shorts/Cs3sTnLO6EE">
<link rel="alternate" media="only screen and (max-width: 640px)" href="https://m.youtube.com/shorts/Cs3sTnLO6EE">
<title> - YouTube</title>
<meta name="title" content="">
<meta name="description" content="Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.">
<meta name="keywords" content="video, sharing, camera phone, video phone, free, upload">
<link rel="alternate" href="android-app://com.google.android.youtube/http/www.youtube.com/shorts/Cs3sTnLO6EE">
<link rel="alternate" href="ios-app://544007664/vnd.youtube/www.youtube.com/shorts/Cs3sTnLO6EE">

我曾以为是 ignore_redirects 导致了这个问题,但修改 FD 选项也没有效果:

我怀疑 YouTube 正在因为与大家相同的 AI 抓取问题而限制抓取,但不确定是什么具体原因导致我们收到空白响应(看起来就像在浏览器中访问时通过 JS 填充了 meta/title 标签)。

这段用于 YouTube oneboxing 的代码期望 title + image 标签被填充:

将继续调查 :eyes:

2 个赞

会不会是他们为了节省带宽而只发送看起来有必要的内容?我们的 Oneboxes 使用浏览器用户代理,所以也许他们只是遵守了这一点?

2 个赞

好的,我认为我这里有一个修复方法,我们应该改用 YouTube 的 oEmbed 来处理这些内容:

我不这么认为,这似乎是两件事:

  1. 某种奇怪的 IP 速率限制/重定向,因为有时对于我们托管上的不同站点,OP 链接会起作用
  2. 这段代码不再有效,因为我们期望的 JSON 不再存在 discourse/lib/onebox/engine/youtube_onebox.rb at e144ec07c8c17ad0f73427524bccc10c074d5a19 · discourse/discourse · GitHub

总的来说,oEmbed URL 似乎更安全,对于 OP 视频,它是 https://www.youtube.com/oembed?url=https://youtube.com/shorts/Cs3sTnLO6EE&format=json,你会得到类似这样的响应:

2 个赞

好的,该修复程序已合并,现在可以正常工作了 :slight_smile:

请注意,onebox URL 的响应会被缓存 1 天,我必须在控制台中执行 Oneboxer.preview(“https://youtube.com/shorts/Cs3sTnLO6EE”, invalidate_oneboxes: true) 才能看到新的结果。

3 个赞

此主题在 2 天后自动关闭。不再允许回复。