martin
(Martin Brennan)
11 نوفمبر 2025، 6:49ص
13
حسنًا، أعتقد أن لدي حلاً هنا، يجب أن نستخدم oEmbed لهذه الأشياء من يوتيوب بدلاً من ذلك:
main ← issue/youtube-oneboxes
opened 06:39AM - 11 Nov 25 UTC
We currently rely on Open Graph data to render YouTube oneboxes.
However, YouTu… be does not always give us a response with the Open Graph
data necessary, leading to empty preview HTML like this that shows
as a broken image in the composer:
```
<img src="" width="480" height="360" title=" - YouTube" style="aspect-ratio: 480 / 360;">
```
In addition, our old method of parsing YouTube script tags for JSON
which contains information for the video, introduced in
https://github.com/discourse/onebox/commit/4d669d2b710483281df1b99ff1140acdada11286,
seems to no longer work reliably, possibly due to changes in YouTube's
JS structure.
To fix this, we switch to using YouTube's oEmbed endpoint which gives us
all the metadata we need for oneboxes in JSON format, including title, author,
thumbnail URL, and video dimensions. This approach is more robust and less likely to break
due to changes in YouTube's page structure.
c.f. https://meta.discourse.org/t/youtube-uris-fail-to-render-thumbnails-when-oneboxed/387673
لا أعتقد ذلك، يبدو أن هناك شيئين:
نوع من تحديد المعدل/إعادة التوجيه الغريب لعنوان IP، لأن أحيانًا بالنسبة لمواقع مختلفة على استضافتنا، يعمل رابط OP.
هذا الكود لم يعد يعمل، لأن JSON الذي نتوقعه لم يعد موجودًا discourse/lib/onebox/engine/youtube_onebox.rb at e144ec07c8c17ad0f73427524bccc10c074d5a19 · discourse/discourse · GitHub
بشكل عام، يبدو عنوان URL الخاص بـ oEmbed أكثر أمانًا، بالنسبة لمقطع الفيديو الخاص بـ OP، فهو https://www.youtube.com/oembed?url=https://youtube.com/shorts/Cs3sTnLO6EE&format=json وتحصل على هذا النوع من الاستجابة:
إعجابَين (2)