mirror of
https://gitea.invidious.io/iv-org/invidious.git
synced 2024-08-15 00:53:41 +00:00
Code quality fixes
This commit is contained in:
parent
503ace90f5
commit
93a6464bbe
6 changed files with 9 additions and 19 deletions
|
@ -191,8 +191,6 @@ module Invidious::Routes::Embed
|
||||||
|
|
||||||
thumbnail = "/vi/#{video.id}/maxres.jpg"
|
thumbnail = "/vi/#{video.id}/maxres.jpg"
|
||||||
|
|
||||||
chapters = video.chapters
|
|
||||||
|
|
||||||
if params.raw
|
if params.raw
|
||||||
url = fmt_stream[0]["url"].as_s
|
url = fmt_stream[0]["url"].as_s
|
||||||
|
|
||||||
|
|
|
@ -160,14 +160,10 @@ module Invidious::Routes::Images
|
||||||
id = env.params.url["id"]
|
id = env.params.url["id"]
|
||||||
name = env.params.url["name"]
|
name = env.params.url["name"]
|
||||||
|
|
||||||
# Sometimes required to fetch image. IE for chapter thumbnails
|
# Some thumbnails such as the ones for chapters requires some additional queries.
|
||||||
query_params = HTTP::Params.new
|
query_params = HTTP::Params.new
|
||||||
if sqp = env.params.query["sqp"]?
|
{"sqp", "rs"}.each do |name|
|
||||||
query_params["sqp"] = sqp
|
query_params[name] = env.params.query[name] if env.params.query[name]?
|
||||||
end
|
|
||||||
|
|
||||||
if rs = env.params.query["rs"]?
|
|
||||||
query_params["rs"] = rs
|
|
||||||
end
|
end
|
||||||
|
|
||||||
headers = HTTP::Headers.new
|
headers = HTTP::Headers.new
|
||||||
|
|
|
@ -158,8 +158,6 @@ module Invidious::Routes::Watch
|
||||||
|
|
||||||
thumbnail = "/vi/#{video.id}/maxres.jpg"
|
thumbnail = "/vi/#{video.id}/maxres.jpg"
|
||||||
|
|
||||||
chapters = video.chapters
|
|
||||||
|
|
||||||
if params.raw
|
if params.raw
|
||||||
if params.listen
|
if params.listen
|
||||||
url = audio_streams[0]["url"].as_s
|
url = audio_streams[0]["url"].as_s
|
||||||
|
|
|
@ -10,8 +10,8 @@ module Invidious::Videos
|
||||||
# Constructs a chapters object from InnerTube's JSON object for chapters
|
# Constructs a chapters object from InnerTube's JSON object for chapters
|
||||||
#
|
#
|
||||||
# Requires the length of the video the chapters are associated to in order to construct correct ending time
|
# Requires the length of the video the chapters are associated to in order to construct correct ending time
|
||||||
def Chapters.from_raw_chapters(raw_chapters : Array(JSON::Any), video_length_seconds : Int32, is_auto_generated : Bool = false)
|
def Chapters.from_raw_chapters(raw_chapters : Array(JSON::Any), video_length : Int32, is_auto_generated : Bool = false)
|
||||||
video_length_milliseconds = video_length_seconds.seconds.total_milliseconds
|
video_length_milliseconds = video_length.seconds.total_milliseconds
|
||||||
|
|
||||||
parsed_chapters = [] of Chapter
|
parsed_chapters = [] of Chapter
|
||||||
|
|
||||||
|
@ -21,10 +21,8 @@ module Invidious::Videos
|
||||||
title = chapter["title"]["simpleText"].as_s
|
title = chapter["title"]["simpleText"].as_s
|
||||||
|
|
||||||
raw_thumbnails = chapter["thumbnail"]["thumbnails"].as_a
|
raw_thumbnails = chapter["thumbnail"]["thumbnails"].as_a
|
||||||
thumbnails = [] of Hash(String, Int32 | String)
|
thumbnails = raw_thumbnails.map do |thumbnail|
|
||||||
|
{
|
||||||
raw_thumbnails.each do |thumbnail|
|
|
||||||
thumbnails << {
|
|
||||||
"url" => thumbnail["url"].as_s,
|
"url" => thumbnail["url"].as_s,
|
||||||
"width" => thumbnail["width"].as_i,
|
"width" => thumbnail["width"].as_i,
|
||||||
"height" => thumbnail["height"].as_i,
|
"height" => thumbnail["height"].as_i,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<% if !chapters.nil? %>
|
<% if chapters = video.chapters %>
|
||||||
<div class="description-chapters-section">
|
<div class="description-chapters-section">
|
||||||
<hr class="description-content-separator"/>
|
<hr class="description-content-separator"/>
|
||||||
<h4><%=HTML.escape(translate(locale, "video_chapters_label"))%></h4>
|
<h4><%=HTML.escape(translate(locale, "video_chapters_label"))%></h4>
|
||||||
|
|
|
@ -64,7 +64,7 @@
|
||||||
<track kind="captions" src="/api/v1/captions/<%= video.id %>?label=<%= caption.name %>" label="<%= caption.name %>">
|
<track kind="captions" src="/api/v1/captions/<%= video.id %>?label=<%= caption.name %>" label="<%= caption.name %>">
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if !chapters.nil? %>
|
<% if !video.chapters.nil? %>
|
||||||
<track kind="chapters" src="/api/v1/chapters/<%= video.id %>">
|
<track kind="chapters" src="/api/v1/chapters/<%= video.id %>">
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
Loading…
Reference in a new issue