From 629ec02b8c1a9d918289ba4c370da4628d080788 Mon Sep 17 00:00:00 2001 From: "@CyberAndi" Date: Thu, 8 Feb 2024 20:40:27 +0100 Subject: [PATCH] Create watch_page_n.cr --- src/invidious/frontend/watch_page_n.cr | 107 +++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 src/invidious/frontend/watch_page_n.cr diff --git a/src/invidious/frontend/watch_page_n.cr b/src/invidious/frontend/watch_page_n.cr new file mode 100644 index 00000000..c8cb7110 --- /dev/null +++ b/src/invidious/frontend/watch_page_n.cr @@ -0,0 +1,107 @@ +module Invidious::Frontend::WatchPage + extend self + + # A handy structure to pass many elements at + # once to the download widget function + struct VideoAssets + getter full_videos : Array(Hash(String, JSON::Any)) + getter video_streams : Array(Hash(String, JSON::Any)) + getter audio_streams : Array(Hash(String, JSON::Any)) + getter captions : Array(Invidious::Videos::Captions::Metadata) + + def initialize( + @full_videos, + @video_streams, + @audio_streams, + @captions + ) + end + end + + def download_widget(locale : String, video : Video, video_assets : VideoAssets) : String + if CONFIG.disabled?("downloads") + return "

#{translate(locale, "Download is disabled")}

" + end + + return String.build(4000) do |str| + str << "" + str << '\n' + + # Hidden inputs for video id and title + str << "\n" + str << "\n" + + str << "\t
\n" + + str << "\t\t\n" + + str << "\t\t\n" + str << "\t
\n" + + str << "\t\n" + + str << "\n" + end + end +end