-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Towards using only next endpoint for the major data. (Partial solution to #5003) #5237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
637aef8
fe73551
a9dfc70
70acf7c
b2f7d07
2a33036
30b5938
ed2827b
bcd1f85
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,10 +73,6 @@ def error_template_helper(env : HTTP::Server::Context, status_code : Int32, exce | |
</div> | ||
END_HTML | ||
|
||
# Don't show the usual "next steps" widget. The same options are | ||
# proposed above the error message, just worded differently. | ||
next_steps = "" | ||
|
||
return templated "error" | ||
end | ||
|
||
|
@@ -86,8 +82,13 @@ def error_template_helper(env : HTTP::Server::Context, status_code : Int32, mess | |
|
||
locale = env.get("preferences").as(Preferences).locale | ||
|
||
error_message = translate(locale, message) | ||
next_steps = error_redirect_helper(env) | ||
error_message = <<-END_HTML | ||
<div class="error_message"> | ||
<h2>#{translate(locale, "error_processing_data_youtube")}</h2> | ||
<p>#{translate(locale, message)}</p> | ||
#{error_redirect_helper(env)} | ||
</div> | ||
END_HTML | ||
Comment on lines
+85
to
+91
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copy and pasted from my review from the original PR:
|
||
|
||
return templated "error" | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -313,7 +313,7 @@ def get_video(id, refresh = true, region = nil, force_refresh = false) | |
end | ||
else | ||
video = fetch_video(id, region) | ||
Invidious::Database::Videos.insert(video) if !region | ||
Invidious::Database::Videos.insert(video) if !region && !video.info.dig?("reason") | ||
end | ||
|
||
return video | ||
|
@@ -326,13 +326,13 @@ end | |
def fetch_video(id, region) | ||
info = extract_video_info(video_id: id) | ||
|
||
if reason = info["reason"]? | ||
if info["reason"]? && info["subreason"]? | ||
reason = info["reason"].as_s | ||
subreason = info["subreason"].as_s | ||
if reason == "Video unavailable" | ||
raise NotFoundException.new(reason.as_s || "") | ||
elsif !reason.as_s.starts_with? "Premieres" | ||
# dont error when it's a premiere. | ||
# we already parsed most of the data and display the premiere date | ||
raise InfoException.new(reason.as_s || "") | ||
raise NotFoundException.new(reason + ": Video not found" || "") | ||
elsif {"Private video"}.any?(reason) | ||
raise InfoException.new(reason + ": " + subreason || "") | ||
end | ||
Comment on lines
+331
to
336
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'll should be cleaner to use a case statement here https://crystal-lang.org/reference/1.16/syntax_and_semantics/case.html |
||
end | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -68,18 +68,20 @@ def extract_video_info(video_id : String) | |||||||||||
playability_status = player_response.dig?("playabilityStatus", "status").try &.as_s | ||||||||||||
|
||||||||||||
if playability_status != "OK" | ||||||||||||
subreason = player_response.dig?("playabilityStatus", "errorScreen", "playerErrorMessageRenderer", "subreason") | ||||||||||||
reason = subreason.try &.[]?("simpleText").try &.as_s | ||||||||||||
reason ||= subreason.try &.[]("runs").as_a.map(&.[]("text")).join("") | ||||||||||||
reason ||= player_response.dig("playabilityStatus", "reason").as_s | ||||||||||||
|
||||||||||||
# Stop here if video is not a scheduled livestream or | ||||||||||||
# for LOGIN_REQUIRED when videoDetails element is not found because retrying won't help | ||||||||||||
if !{"LIVE_STREAM_OFFLINE", "LOGIN_REQUIRED"}.any?(playability_status) || | ||||||||||||
playability_status == "LOGIN_REQUIRED" && !player_response.dig?("videoDetails") | ||||||||||||
reason = player_response.dig?("playabilityStatus", "reason").try &.as_s | ||||||||||||
reason ||= player_response.dig("playabilityStatus", "errorScreen", "playerErrorMessageRenderer", "reason", "simpleText").as_s | ||||||||||||
subreason_main = player_response.dig?("playabilityStatus", "errorScreen", "playerErrorMessageRenderer", "subreason") | ||||||||||||
subreason = subreason_main.try &.[]?("simpleText").try &.as_s | ||||||||||||
subreason ||= subreason_main.try &.[]("runs").as_a.map(&.[]("text")).join("") | ||||||||||||
Comment on lines
+71
to
+75
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's quite a few redundant digs in here. What do you think about doing something like this instead? playability_status_object = player_response["playabilityStatus"]
playability_status = playability_status_object["status"]?.try &.as_s
if playability_status != "OK"
reason = playability_status_object["status"]?.try(&.as_s)
subreason = nil
playability_status_object.dig?("errorScreen", "playerErrorMessageRenderer").try do | playability_error_renderer |
# If we weren't able to extract a reason earlier
# try finding one in "playerErrorMessageRenderer"
reason ||= playability_error_renderer.dig("reason", "simpleText").as_s
break unless (subreason_container = playability_error_renderer["subreason"]?)
# Subreason may exist under a "simpleText" or "runs" construct.
subreason = subreason_container["simpleText"]?.try(&.as_s) ||
subreason_container["runs"]?.try(&.as_a.map(&.["text"]).join)
end
|
||||||||||||
|
||||||||||||
# Stop if private video or video not found. | ||||||||||||
# But for video unavailable, only stop if playability_status is ERROR because playability_status UNPLAYABLE | ||||||||||||
# still gives all the necessary info for displaying the video page (title, description and more) | ||||||||||||
if {"Private video", "Video unavailable"}.any?(reason) && !{"UNPLAYABLE"}.any?(playability_status) | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
return { | ||||||||||||
"version" => JSON::Any.new(Video::SCHEMA_VERSION.to_i64), | ||||||||||||
"reason" => JSON::Any.new(reason), | ||||||||||||
"version" => JSON::Any.new(Video::SCHEMA_VERSION.to_i64), | ||||||||||||
"reason" => JSON::Any.new(reason), | ||||||||||||
"subreason" => JSON::Any.new(subreason), | ||||||||||||
} | ||||||||||||
end | ||||||||||||
elsif video_id != player_response.dig("videoDetails", "videoId") | ||||||||||||
|
@@ -99,11 +101,8 @@ def extract_video_info(video_id : String) | |||||||||||
reason = nil | ||||||||||||
end | ||||||||||||
|
||||||||||||
# Don't fetch the next endpoint if the video is unavailable. | ||||||||||||
if {"OK", "LIVE_STREAM_OFFLINE", "LOGIN_REQUIRED"}.any?(playability_status) | ||||||||||||
next_response = YoutubeAPI.next({"videoId": video_id, "params": ""}) | ||||||||||||
player_response = player_response.merge(next_response) | ||||||||||||
end | ||||||||||||
next_response = YoutubeAPI.next({"videoId": video_id, "params": ""}) | ||||||||||||
player_response = player_response.merge(next_response) | ||||||||||||
|
||||||||||||
params = parse_video_info(video_id, player_response) | ||||||||||||
params["reason"] = JSON::Any.new(reason) if reason | ||||||||||||
|
@@ -197,16 +196,20 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any | |||||||||||
end | ||||||||||||
|
||||||||||||
video_details = player_response.dig?("videoDetails") | ||||||||||||
video_details ||= {} of String => JSON::Any | ||||||||||||
if !(microformat = player_response.dig?("microformat", "playerMicroformatRenderer")) | ||||||||||||
microformat = {} of String => JSON::Any | ||||||||||||
end | ||||||||||||
Comment on lines
198
to
202
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||
|
||||||||||||
raise BrokenTubeException.new("videoDetails") if !video_details | ||||||||||||
|
||||||||||||
# Basic video infos | ||||||||||||
|
||||||||||||
title = video_details["title"]?.try &.as_s | ||||||||||||
|
||||||||||||
title ||= extract_text( | ||||||||||||
video_primary_renderer | ||||||||||||
.try &.dig?("title") | ||||||||||||
) | ||||||||||||
Comment on lines
+208
to
+211
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
||||||||||||
# We have to try to extract viewCount from videoPrimaryInfoRenderer first, | ||||||||||||
# then from videoDetails, as the latter is "0" for livestreams (we want | ||||||||||||
# to get the amount of viewers watching). | ||||||||||||
|
@@ -217,12 +220,25 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any | |||||||||||
views_txt ||= video_details["viewCount"]?.try &.as_s || "" | ||||||||||||
views = views_txt.gsub(/\D/, "").to_i64? | ||||||||||||
|
||||||||||||
length_txt = (microformat["lengthSeconds"]? || video_details["lengthSeconds"]) | ||||||||||||
length_txt = (microformat["lengthSeconds"]? || video_details["lengthSeconds"]?) | ||||||||||||
.try &.as_s.to_i64 | ||||||||||||
|
||||||||||||
published = microformat["publishDate"]? | ||||||||||||
.try { |t| Time.parse(t.as_s, "%Y-%m-%d", Time::Location::UTC) } || Time.utc | ||||||||||||
|
||||||||||||
if published.nil? | ||||||||||||
published_txt = video_primary_renderer | ||||||||||||
.try &.dig?("dateText", "simpleText") | ||||||||||||
|
||||||||||||
if published_txt.try &.as_s.includes?("ago") && !published_txt.nil? | ||||||||||||
published = decode_date(published_txt.as_s.lchop("Started streaming ")) | ||||||||||||
elsif published_txt && published_txt.try &.as_s.matches?(/(\w{3} \d{1,2}, \d{4})$/) | ||||||||||||
published = Time.parse(published_txt.as_s.match!(/(\w{3} \d{1,2}, \d{4})$/)[0], "%b %-d, %Y", Time::Location::UTC) | ||||||||||||
else | ||||||||||||
published = Time.utc | ||||||||||||
end | ||||||||||||
Comment on lines
+230
to
+239
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something like this should be more efficient video_primary_renderer.try(&.dig?("dateText", "simpleText")).try do | published_txt |
published_txt = published_txt.as_s
published = if published_txt.includes?("ago")
decode_date(published_txt.lchop("Started streaming "))
elsif matched_time = published_txt.match(/(\w{3} \d{1,2}, \d{4})$/)
Time.parse(matched_time[0], "%b %-d, %Y", Time::Location::UTC)
end
end
published ||= Time.utc There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please also try using the https://github.com/iv-org/invidious/pull/5003/files#r1807376801 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, thanks for your feedback! Unfortunately I know almost nothing about crystal so I'd rather not try and implement actual changes. In this PR I just rebased @unixfox's code in hopes to get it merged asap to avoid even more branch divergence and thus even more effort for rebasing. I hope it's not too late already. If it's important to you that I update the PR, I can try and apply all the changes you requested. However, since those are your changes, wouldn't it be more clear to merge and then apply them, rather than having me apply them in unixfox's or your name? (Evem deciding that for each patch seems needlessly error-prone.) Except of course if any of the patches introduce a critical bug, then obviously I should fix the offending code before it's merged. If so, please tell me, because I'm unable to classify the kind of changes you made. For any code that's not actually "bad" but just "could be better" (e.g. "should be more efficient"), let's make improvements a separate PR. After all, this PR is titled "Towards … (Partial solution …)" because I know it's not perfect, it's just a useful step, or at least I hope it is. And since most contributors here have a tendency to only occasionally have time for this project, I think merging acceptable parts as early as possible is a good approach. |
||||||||||||
end | ||||||||||||
|
||||||||||||
premiere_timestamp = microformat.dig?("liveBroadcastDetails", "startTimestamp") | ||||||||||||
.try { |t| Time.parse_rfc3339(t.as_s) } | ||||||||||||
|
||||||||||||
|
@@ -236,6 +252,10 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any | |||||||||||
|
||||||||||||
live_now = microformat.dig?("liveBroadcastDetails", "isLiveNow") | ||||||||||||
.try &.as_bool | ||||||||||||
if live_now.nil? | ||||||||||||
live_now = video_primary_renderer | ||||||||||||
.try &.dig?("viewCount", "videoViewCountRenderer", "isLive").try &.as_bool | ||||||||||||
end | ||||||||||||
Comment on lines
+255
to
+258
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
live_now ||= video_details.dig?("isLive").try &.as_bool || false | ||||||||||||
|
||||||||||||
post_live_dvr = video_details.dig?("isPostLiveDvr") | ||||||||||||
|
@@ -247,8 +267,23 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any | |||||||||||
.try &.as_a.map &.as_s || [] of String | ||||||||||||
|
||||||||||||
allow_ratings = video_details["allowRatings"]?.try &.as_bool | ||||||||||||
|
||||||||||||
family_friendly = microformat["isFamilySafe"]?.try &.as_bool | ||||||||||||
if family_friendly.nil? | ||||||||||||
family_friendly = true # if isFamilySafe not found then assume is safe | ||||||||||||
end | ||||||||||||
syeopite marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
|
||||||||||||
is_listed = video_details["isCrawlable"]?.try &.as_bool | ||||||||||||
if is_listed.nil? | ||||||||||||
if video_badges = video_primary_renderer.try &.dig?("badges") | ||||||||||||
is_listed = !has_unlisted_badge?(video_badges) | ||||||||||||
else | ||||||||||||
# If video has no badges and videoDetails is not | ||||||||||||
# available, then assume isListed | ||||||||||||
is_listed = true | ||||||||||||
end | ||||||||||||
end | ||||||||||||
|
||||||||||||
is_upcoming = video_details["isUpcoming"]?.try &.as_bool | ||||||||||||
|
||||||||||||
keywords = video_details["keywords"]? | ||||||||||||
|
@@ -414,6 +449,9 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any | |||||||||||
subs_text = author_info["subscriberCountText"]? | ||||||||||||
.try { |t| t["simpleText"]? || t.dig?("runs", 0, "text") } | ||||||||||||
.try &.as_s.split(" ", 2)[0] | ||||||||||||
|
||||||||||||
author ||= author_info.dig?("title", "runs", 0, "text").try &.as_s | ||||||||||||
ucid ||= author_info.dig?("title", "runs", 0, "navigationEndpoint", "browseEndpoint", "browseId").try &.as_s | ||||||||||||
end | ||||||||||||
|
||||||||||||
# Return data | ||||||||||||
|
@@ -438,8 +476,8 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any | |||||||||||
# Extra video infos | ||||||||||||
"allowedRegions" => JSON::Any.new(allowed_regions.map { |v| JSON::Any.new(v) }), | ||||||||||||
"allowRatings" => JSON::Any.new(allow_ratings || false), | ||||||||||||
"isFamilyFriendly" => JSON::Any.new(family_friendly || false), | ||||||||||||
"isListed" => JSON::Any.new(is_listed || false), | ||||||||||||
"isFamilyFriendly" => JSON::Any.new(family_friendly), | ||||||||||||
"isListed" => JSON::Any.new(is_listed), | ||||||||||||
"isUpcoming" => JSON::Any.new(is_upcoming || false), | ||||||||||||
"keywords" => JSON::Any.new(keywords.map { |v| JSON::Any.new(v) }), | ||||||||||||
"isPostLiveDvr" => JSON::Any.new(post_live_dvr), | ||||||||||||
|
@@ -448,7 +486,7 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any | |||||||||||
# Description | ||||||||||||
"description" => JSON::Any.new(description || ""), | ||||||||||||
"descriptionHtml" => JSON::Any.new(description_html || "<p></p>"), | ||||||||||||
"shortDescription" => JSON::Any.new(short_description.try &.as_s || nil), | ||||||||||||
"shortDescription" => JSON::Any.new(short_description.try &.as_s || ""), | ||||||||||||
Comment on lines
-451
to
+489
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no idea. @unixfox , do you still remember? |
||||||||||||
# Video metadata | ||||||||||||
"genre" => JSON::Any.new(genre.try &.as_s || ""), | ||||||||||||
"genreUcid" => JSON::Any.new(genre_ucid.try &.as_s?), | ||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -31,7 +31,17 @@ | |||||||||||||||||||||||||||||||||||||
%> | ||||||||||||||||||||||||||||||||||||||
</script> | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
<%= rendered "components/player" %> | ||||||||||||||||||||||||||||||||||||||
<% if video.reason.nil? %> | ||||||||||||||||||||||||||||||||||||||
<div id="player-container" class="h-box"> | ||||||||||||||||||||||||||||||||||||||
<%= rendered "components/player" %> | ||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||
<% else %> | ||||||||||||||||||||||||||||||||||||||
<div id="player-error-container" class="h-box"> | ||||||||||||||||||||||||||||||||||||||
<h3> | ||||||||||||||||||||||||||||||||||||||
<%= video.reason %> | ||||||||||||||||||||||||||||||||||||||
</h3> | ||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||
Comment on lines
+35
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||
<% end %> | ||||||||||||||||||||||||||||||||||||||
<script src="/js/embed.js?v=<%= ASSET_COMMIT %>"></script> | ||||||||||||||||||||||||||||||||||||||
</body> | ||||||||||||||||||||||||||||||||||||||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,4 @@ | |
|
||
<div class="h-box"> | ||
<%= error_message %> | ||
<%= next_steps %> | ||
</div> |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -70,9 +70,11 @@ we're going to need to do it here in order to allow for translations. | |||||||||||||||||||||||||||||
%> | ||||||||||||||||||||||||||||||
</script> | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
<% if video.reason.nil? %> | ||||||||||||||||||||||||||||||
<div id="player-container" class="h-box"> | ||||||||||||||||||||||||||||||
<%= rendered "components/player" %> | ||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||
<% end %> | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
<div class="h-box"> | ||||||||||||||||||||||||||||||
<h1> | ||||||||||||||||||||||||||||||
|
@@ -96,7 +98,10 @@ we're going to need to do it here in order to allow for translations. | |||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
<% if video.reason %> | ||||||||||||||||||||||||||||||
<h3> | ||||||||||||||||||||||||||||||
<%= video.reason %> | ||||||||||||||||||||||||||||||
<%= translate(locale, "error_from_youtube_unplayable") %> <%= video.reason %> | ||||||||||||||||||||||||||||||
</h3> | ||||||||||||||||||||||||||||||
<h3> | ||||||||||||||||||||||||||||||
<%= translate(locale, "next_steps_error_message") %> | ||||||||||||||||||||||||||||||
</h3> | ||||||||||||||||||||||||||||||
<% elsif video.premiere_timestamp.try &.> Time.utc %> | ||||||||||||||||||||||||||||||
<h3> | ||||||||||||||||||||||||||||||
|
@@ -112,7 +117,7 @@ we're going to need to do it here in order to allow for translations. | |||||||||||||||||||||||||||||
<div class="pure-g"> | ||||||||||||||||||||||||||||||
<div class="pure-u-1 pure-u-lg-1-5"> | ||||||||||||||||||||||||||||||
<div class="h-box"> | ||||||||||||||||||||||||||||||
<span id="watch-on-youtube"> | ||||||||||||||||||||||||||||||
<p id="watch-on-youtube"> | ||||||||||||||||||||||||||||||
<%- | ||||||||||||||||||||||||||||||
link_yt_watch = URI.new(scheme: "https", host: "www.youtube.com", path: "/watch", query: "v=#{video.id}") | ||||||||||||||||||||||||||||||
link_yt_embed = URI.new(scheme: "https", host: "www.youtube.com", path: "/embed/#{video.id}") | ||||||||||||||||||||||||||||||
|
@@ -125,7 +130,7 @@ we're going to need to do it here in order to allow for translations. | |||||||||||||||||||||||||||||
-%> | ||||||||||||||||||||||||||||||
<a id="link-yt-watch" rel="noreferrer noopener" data-base-url="<%= link_yt_watch %>" href="<%= link_yt_watch %>"><%= translate(locale, "videoinfo_watch_on_youTube") %></a> | ||||||||||||||||||||||||||||||
(<a id="link-yt-embed" rel="noreferrer noopener" data-base-url="<%= link_yt_embed %>" href="<%= link_yt_embed %>"><%= translate(locale, "videoinfo_youTube_embed_link") %></a>) | ||||||||||||||||||||||||||||||
</span> | ||||||||||||||||||||||||||||||
</p> | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
<p id="watch-on-another-invidious-instance"> | ||||||||||||||||||||||||||||||
<%- link_iv_other = IV::Frontend::Misc.redirect_url(env) -%> | ||||||||||||||||||||||||||||||
|
@@ -185,18 +190,22 @@ we're going to need to do it here in order to allow for translations. | |||||||||||||||||||||||||||||
<% end %> | ||||||||||||||||||||||||||||||
<% end %> | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
<% if video_assets %> | ||||||||||||||||||||||||||||||
<%= Invidious::Frontend::WatchPage.download_widget(locale, video, video_assets) %> | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please indent
Suggested change
|
||||||||||||||||||||||||||||||
<% end %> | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
<p id="views"><i class="icon ion-ios-eye"></i> <%= number_with_separator(video.views) %></p> | ||||||||||||||||||||||||||||||
<p id="likes"><i class="icon ion-ios-thumbs-up"></i> <%= number_with_separator(video.likes) %></p> | ||||||||||||||||||||||||||||||
<p id="dislikes" style="display: none; visibility: hidden;"></p> | ||||||||||||||||||||||||||||||
<% if video.genre %> | ||||||||||||||||||||||||||||||
<p id="genre"><%= translate(locale, "Genre: ") %> | ||||||||||||||||||||||||||||||
<% if !video.genre_url %> | ||||||||||||||||||||||||||||||
<%= video.genre %> | ||||||||||||||||||||||||||||||
<% else %> | ||||||||||||||||||||||||||||||
<a href="<%= video.genre_url %>"><%= video.genre %></a> | ||||||||||||||||||||||||||||||
<% end %> | ||||||||||||||||||||||||||||||
</p> | ||||||||||||||||||||||||||||||
Comment on lines
201
to
207
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please indent
Suggested change
|
||||||||||||||||||||||||||||||
<% end %> | ||||||||||||||||||||||||||||||
<% if video.license %> | ||||||||||||||||||||||||||||||
<% if video.license.empty? %> | ||||||||||||||||||||||||||||||
<p id="license"><%= translate(locale, "License: ") %><%= translate(locale, "Standard YouTube license") %></p> | ||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -68,6 +68,23 @@ rescue ex | |||||||||||||||||||||||||||||||||||||
return false | ||||||||||||||||||||||||||||||||||||||
end | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
def has_unlisted_badge?(badges : JSON::Any?) | ||||||||||||||||||||||||||||||||||||||
return false if badges.nil? | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
badges.as_a.each do |badge| | ||||||||||||||||||||||||||||||||||||||
icon_type = badge.dig("metadataBadgeRenderer", "icon", "iconType").as_s | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
return true if icon_type == "PRIVACY_UNLISTED" | ||||||||||||||||||||||||||||||||||||||
end | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
return false | ||||||||||||||||||||||||||||||||||||||
Comment on lines
+72
to
+80
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||
rescue ex | ||||||||||||||||||||||||||||||||||||||
LOGGER.debug("Unable to parse owner badges. Got exception: #{ex.message}") | ||||||||||||||||||||||||||||||||||||||
LOGGER.trace("Owner badges data: #{badges.to_json}") | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
return false | ||||||||||||||||||||||||||||||||||||||
Comment on lines
+72
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This entire function could pretty much be reduced down to a single line. I don't know if the error handling + logging is intentional here but it shouldn't even be needed if you just use a
Suggested change
|
||||||||||||||||||||||||||||||||||||||
end | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
# This function extracts SearchVideo items from a Category. | ||||||||||||||||||||||||||||||||||||||
# Categories are commonly returned in search results and trending pages. | ||||||||||||||||||||||||||||||||||||||
def extract_category(category : Category) : Array(SearchVideo) | ||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.