mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2026-01-30 18:51:17 +00:00
Add API endpoint to fetch YouTube transcripts
This commit is contained in:
@@ -122,5 +122,40 @@ module Invidious::Videos
|
||||
|
||||
return vtt
|
||||
end
|
||||
|
||||
def to_json(json : JSON::Builder)
|
||||
json.field "languageCode", @language_code
|
||||
json.field "autoGenerated", @auto_generated
|
||||
json.field "label", @label
|
||||
json.field "body" do
|
||||
json.array do
|
||||
@lines.each do |line|
|
||||
json.object do
|
||||
if line.is_a? HeadingLine
|
||||
json.field "type", "heading"
|
||||
else
|
||||
json.field "type", "regular"
|
||||
end
|
||||
|
||||
json.field "startMs", line.start_ms.total_milliseconds
|
||||
json.field "endMs", line.end_ms.total_milliseconds
|
||||
json.field "line", line.line
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def to_json
|
||||
JSON.build do |json|
|
||||
json.object do
|
||||
json.field "transcript" do
|
||||
json.object do
|
||||
to_json(json)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user