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

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 4849286814
Signed by: Fijxu
GPG key ID: 32C1DDF333EDA6A4
2 changed files with 14 additions and 5 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,11 +13,13 @@
<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">
<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:width" content="1280">
<meta property="og:video:height" content="720">
<!-- This shouldn't be empty, ever. -->
<meta property="og:video" content="<%= video_url %>">
<meta property="og:video:url" content="<%= video_url %>">
<meta property="og:video:secure_url" content="<%= video_url %>">
<meta property="og:video:type" content="video/mp4">
<meta property="og:video:width" content="640">
<meta property="og:video:height" content="360">
<meta name="twitter:card" content="player">
<meta name="twitter:url" content="<%= HOST_URL %>/watch?v=<%= video.id %>">
<meta name="twitter:title" content="<%= title %>">