Videos: Add support for OpenGraph videos
All checks were successful
Invidious CI / build (push) Successful in 5m29s

To support OpenGraph clients like Discord and other platforms able to
pull the video from the OpenGraph metadata.
This commit is contained in:
Fijxu 2024-11-04 23:15:16 -03:00
parent e3da8f408d
commit 51e8044ad9
Signed by: Fijxu
GPG key ID: 32C1DDF333EDA6A4
2 changed files with 10 additions and 1 deletions

View file

@ -152,6 +152,7 @@ module Invidious::Routes::Watch
end
end
# Removes non default audio tracks
audio_streams.reject! do |z|
z if z.dig?("audioTrack", "audioIsDefault") == false
end
@ -218,6 +219,12 @@ module Invidious::Routes::Watch
captions: video.captions
)
begin
video_url = "https://#{URI.parse(fmt_stream[0]["url"].to_s).query_params["host"]}#{fmt_stream[0]["url"].to_s}"
rescue
video_url = nil
end
templated "watch"
end

View file

@ -13,9 +13,11 @@
<meta property="og:image" content="<%= HOST_URL %>/vi/<%= video.id %>/maxres.jpg">
<meta property="og:description" content="<%= HTML.escape(video.short_description) %>">
<meta property="og:type" content="video.other">
<!-- This shouldn't be empty, ever. -->
<meta property="og:video" content="<%= video_url %>">
<meta property="og:video:url" content="<%= HOST_URL %>/embed/<%= video.id %>">
<meta property="og:video:secure_url" content="<%= HOST_URL %>/embed/<%= video.id %>">
<meta property="og:video:type" content="text/html">
<meta property="og:video:type" content="video/mp4">
<meta property="og:video:width" content="1280">
<meta property="og:video:height" content="720">
<meta name="twitter:card" content="player">