From 48492868144a7defef483783d4d839b30af0211d Mon Sep 17 00:00:00 2001 From: Fijxu Date: Mon, 4 Nov 2024 23:15:16 -0300 Subject: [PATCH] Videos: Add support for OpenGraph videos To support OpenGraph clients like Discord and other platforms able to pull the video from the OpenGraph metadata. --- src/invidious/routes/watch.cr | 7 +++++++ src/invidious/views/watch.ecr | 12 +++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/invidious/routes/watch.cr b/src/invidious/routes/watch.cr index 2d2050dd..de5f952a 100644 --- a/src/invidious/routes/watch.cr +++ b/src/invidious/routes/watch.cr @@ -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 diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index 70afabcc..e77b0b14 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -13,11 +13,13 @@ - - - - - + + + + + + +