mirror of
https://github.com/iv-org/invidious.git
synced 2024-10-01 01:25:56 -04:00
Code quality fixes
This commit is contained in:
parent
503ace90f5
commit
93a6464bbe
@ -191,8 +191,6 @@ module Invidious::Routes::Embed
|
||||
|
||||
thumbnail = "/vi/#{video.id}/maxres.jpg"
|
||||
|
||||
chapters = video.chapters
|
||||
|
||||
if params.raw
|
||||
url = fmt_stream[0]["url"].as_s
|
||||
|
||||
|
@ -160,14 +160,10 @@ module Invidious::Routes::Images
|
||||
id = env.params.url["id"]
|
||||
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
|
||||
if sqp = env.params.query["sqp"]?
|
||||
query_params["sqp"] = sqp
|
||||
end
|
||||
|
||||
if rs = env.params.query["rs"]?
|
||||
query_params["rs"] = rs
|
||||
{"sqp", "rs"}.each do |name|
|
||||
query_params[name] = env.params.query[name] if env.params.query[name]?
|
||||
end
|
||||
|
||||
headers = HTTP::Headers.new
|
||||
|
@ -158,8 +158,6 @@ module Invidious::Routes::Watch
|
||||
|
||||
thumbnail = "/vi/#{video.id}/maxres.jpg"
|
||||
|
||||
chapters = video.chapters
|
||||
|
||||
if params.raw
|
||||
if params.listen
|
||||
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
|
||||
#
|
||||
# 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)
|
||||
video_length_milliseconds = video_length_seconds.seconds.total_milliseconds
|
||||
def Chapters.from_raw_chapters(raw_chapters : Array(JSON::Any), video_length : Int32, is_auto_generated : Bool = false)
|
||||
video_length_milliseconds = video_length.seconds.total_milliseconds
|
||||
|
||||
parsed_chapters = [] of Chapter
|
||||
|
||||
@ -21,10 +21,8 @@ module Invidious::Videos
|
||||
title = chapter["title"]["simpleText"].as_s
|
||||
|
||||
raw_thumbnails = chapter["thumbnail"]["thumbnails"].as_a
|
||||
thumbnails = [] of Hash(String, Int32 | String)
|
||||
|
||||
raw_thumbnails.each do |thumbnail|
|
||||
thumbnails << {
|
||||
thumbnails = raw_thumbnails.map do |thumbnail|
|
||||
{
|
||||
"url" => thumbnail["url"].as_s,
|
||||
"width" => thumbnail["width"].as_i,
|
||||
"height" => thumbnail["height"].as_i,
|
||||
|
@ -1,4 +1,4 @@
|
||||
<% if !chapters.nil? %>
|
||||
<% if chapters = video.chapters %>
|
||||
<div class="description-chapters-section">
|
||||
<hr class="description-content-separator"/>
|
||||
<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 %>">
|
||||
<% end %>
|
||||
|
||||
<% if !chapters.nil? %>
|
||||
<% if !video.chapters.nil? %>
|
||||
<track kind="chapters" src="/api/v1/chapters/<%= video.id %>">
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
Loading…
Reference in New Issue
Block a user