Add method to generate params for transcripts api

This commit is contained in:
syeopite 2023-07-23 01:52:53 -07:00
parent 7e5935a9da
commit 8e18d445a7
No known key found for this signature in database
GPG key ID: A73C186DA3955A1A

View file

@ -0,0 +1,34 @@
module Invidious::Videos
# Namespace for methods primarily relating to Transcripts
module Transcript
def self.generate_param(video_id : String, language_code : String, auto_generated : Bool) : String
if !auto_generated
is_auto_generated = ""
elsif is_auto_generated = "asr"
end
object = {
"1:0:string" => video_id,
"2:base64" => {
"1:string" => is_auto_generated,
"2:string" => language_code,
"3:string" => "",
},
"3:varint" => 1_i64,
"5:string" => "engagement-panel-searchable-transcript-search-panel",
"6:varint" => 1_i64,
"7:varint" => 1_i64,
"8:varint" => 1_i64,
}
params = object.try { |i| Protodec::Any.cast_json(i) }
.try { |i| Protodec::Any.from_json(i) }
.try { |i| Base64.urlsafe_encode(i) }
.try { |i| URI.encode_www_form(i) }
return params
end
end
end