mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-08 13:42:27 +05:30
Add message for when chapters are auto generated
This commit is contained in:
parent
00d16dff1f
commit
a569b8f3d9
@ -238,6 +238,10 @@ struct Video
|
||||
return @chapters
|
||||
end
|
||||
|
||||
def automatically_generated_chapters? : Bool?
|
||||
return @info["AutoGeneratedChapters"]?.try &.as_bool
|
||||
end
|
||||
|
||||
def hls_manifest_url : String?
|
||||
info.dig?("streamingData", "hlsManifestUrl").try &.as_s
|
||||
end
|
||||
|
@ -392,13 +392,25 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any
|
||||
|
||||
# Chapters
|
||||
chapters_array = [] of JSON::Any
|
||||
chapters_auto_generated = nil
|
||||
|
||||
# Yes, `decoratedPlayerBarRenderer` is repeated twice.
|
||||
# Yes,`decoratedPlayerBarRenderer` is repeated twice.
|
||||
if player_bar = player_overlays.try &.dig?("decoratedPlayerBarRenderer", "decoratedPlayerBarRenderer", "playerBar")
|
||||
if markers = player_bar.dig?("multiMarkersPlayerBarRenderer", "markersMap")
|
||||
potential_chapters_array = markers.as_a.find { |m| m["key"]? == "DESCRIPTION_CHAPTERS" }
|
||||
|
||||
# Let manual chapters have higher precedence than automatically generated ones.
|
||||
if !potential_chapters_array
|
||||
potential_chapters_array = markers.as_a.find { |m| m["key"]? == "AUTO_CHAPTERS" }
|
||||
end
|
||||
|
||||
if potential_chapters_array
|
||||
if potential_chapters_array["key"] == "AUTO_CHAPTERS"
|
||||
chapters_auto_generated = true
|
||||
else
|
||||
chapters_auto_generated = false
|
||||
end
|
||||
|
||||
chapters_array = potential_chapters_array["value"]["chapters"].as_a
|
||||
end
|
||||
end
|
||||
@ -450,7 +462,8 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any
|
||||
"authorVerified" => JSON::Any.new(author_verified || false),
|
||||
"subCountText" => JSON::Any.new(subs_text || "-"),
|
||||
|
||||
"chapters" => JSON::Any.new(chapters_array),
|
||||
"AutoGeneratedChapters" => JSON::Any.new(chapters_auto_generated),
|
||||
"chapters" => JSON::Any.new(chapters_array),
|
||||
}
|
||||
|
||||
return params
|
||||
|
@ -2,6 +2,11 @@
|
||||
<div class="description-chapters-section">
|
||||
<hr class="description-content-separator"/>
|
||||
<h4>Chapters</h4>
|
||||
|
||||
<% if video.automatically_generated_chapters? %>
|
||||
<h5>Chapters are automatically generated </h5>
|
||||
<% end %>
|
||||
|
||||
<div class="description-chapters-content-container">
|
||||
<% chapters.each do | chapter | %>
|
||||
<%- start_in_seconds = chapter.start_ms.milliseconds.total_seconds.to_i %>
|
||||
|
Loading…
Reference in New Issue
Block a user