mirror of
https://github.com/iv-org/invidious.git
synced 2025-07-01 19:18:29 +00:00
Add logic to request transcripts in watch handler
This commit is contained in:
parent
786e40afb0
commit
01b21d9d52
@ -162,8 +162,26 @@ module Invidious::Routes::Watch
|
||||
captions = captions - preferred_captions
|
||||
|
||||
if show_transcripts
|
||||
# Placeholder
|
||||
transcript = true
|
||||
# The transcripts available are the exact same as the amount of captions available. Thus:
|
||||
if !preferred_captions.empty?
|
||||
chosen_transcript = preferred_captions[0]
|
||||
transcript_request_param = Invidious::Videos::Transcript.generate_param(
|
||||
id, chosen_transcript.language_code, chosen_transcript.auto_generated
|
||||
)
|
||||
elsif !captions.empty?
|
||||
chosen_transcript = captions[0]
|
||||
transcript_request_param = Invidious::Videos::Transcript.generate_param(
|
||||
id, chosen_transcript.language_code, chosen_transcript.auto_generated
|
||||
)
|
||||
else
|
||||
return error_template(404, "error_transcripts_none_available")
|
||||
end
|
||||
|
||||
transcript = Invidious::Videos::Transcript.from_raw(
|
||||
YoutubeAPI.get_transcript(transcript_request_param),
|
||||
chosen_transcript.language_code,
|
||||
chosen_transcript.auto_generated,
|
||||
)
|
||||
else
|
||||
transcript = nil
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user