summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsyeopite <syeopite@syeopite.dev>2023-07-22 23:55:05 -0700
committersyeopite <syeopite@syeopite.dev>2023-07-23 14:40:02 -0700
commit2e67b90540d35ede212866e1fb597fd57ced35d5 (patch)
tree3ebe74515c90330423e827e61114238eb5c17c0b /src
parentd956b1826e15da6cfcd9a1531b0f1e6ef577dd10 (diff)
downloadinvidious-2e67b90540d35ede212866e1fb597fd57ced35d5.tar.gz
invidious-2e67b90540d35ede212866e1fb597fd57ced35d5.tar.bz2
invidious-2e67b90540d35ede212866e1fb597fd57ced35d5.zip
Add method to query /youtubei/v1/get_transcript
Diffstat (limited to 'src')
-rw-r--r--src/invidious/yt_backend/youtube_api.cr24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/invidious/yt_backend/youtube_api.cr b/src/invidious/yt_backend/youtube_api.cr
index 3dd9e9d8..f8aca04d 100644
--- a/src/invidious/yt_backend/youtube_api.cr
+++ b/src/invidious/yt_backend/youtube_api.cr
@@ -558,6 +558,30 @@ module YoutubeAPI
end
####################################################################
+ # transcript(params)
+ #
+ # Requests the youtubei/v1/get_transcript endpoint with the required headers
+ # and POST data in order to get a JSON reply.
+ #
+ # The requested data is a specially encoded protobuf string that denotes the specific language requested.
+ #
+ # An optional ClientConfig parameter can be passed, too (see
+ # `struct ClientConfig` above for more details).
+ #
+
+ def transcript(
+ params : String,
+ client_config : ClientConfig | Nil = nil
+ ) : Hash(String, JSON::Any)
+ data = {
+ "context" => self.make_context(client_config),
+ "params" => params,
+ }
+
+ return self._post_json("/youtubei/v1/get_transcript", data, client_config)
+ end
+
+ ####################################################################
# _post_json(endpoint, data, client_config?)
#
# Internal function that does the actual request to youtube servers