Fix thin mode
This commit is contained in:
parent
63be05146d
commit
7a0f0ca5ce
@ -307,9 +307,7 @@ get "/watch" do |env|
|
|||||||
nojs ||= "0"
|
nojs ||= "0"
|
||||||
nojs = nojs == "1"
|
nojs = nojs == "1"
|
||||||
|
|
||||||
if env.get? "preferences"
|
preferences = env.get("preferences").as(Preferences)
|
||||||
preferences = env.get("preferences").as(Preferences)
|
|
||||||
end
|
|
||||||
|
|
||||||
if env.get? "user"
|
if env.get? "user"
|
||||||
user = env.get("user").as(User)
|
user = env.get("user").as(User)
|
||||||
@ -344,7 +342,7 @@ get "/watch" do |env|
|
|||||||
|
|
||||||
if source == "youtube"
|
if source == "youtube"
|
||||||
begin
|
begin
|
||||||
comment_html = JSON.parse(fetch_youtube_comments(id, PG_DB, nil, proxies, "html", locale, region))["contentHtml"]
|
comment_html = JSON.parse(fetch_youtube_comments(id, PG_DB, nil, proxies, "html", locale, preferences.thin_mode, region))["contentHtml"]
|
||||||
rescue ex
|
rescue ex
|
||||||
if preferences.comments[1] == "reddit"
|
if preferences.comments[1] == "reddit"
|
||||||
comments, reddit_thread = fetch_reddit_comments(id)
|
comments, reddit_thread = fetch_reddit_comments(id)
|
||||||
@ -363,12 +361,12 @@ get "/watch" do |env|
|
|||||||
comment_html = replace_links(comment_html)
|
comment_html = replace_links(comment_html)
|
||||||
rescue ex
|
rescue ex
|
||||||
if preferences.comments[1] == "youtube"
|
if preferences.comments[1] == "youtube"
|
||||||
comment_html = JSON.parse(fetch_youtube_comments(id, PG_DB, nil, proxies, "html", locale, region))["contentHtml"]
|
comment_html = JSON.parse(fetch_youtube_comments(id, PG_DB, nil, proxies, "html", locale, preferences.thin_mode, region))["contentHtml"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
comment_html = JSON.parse(fetch_youtube_comments(id, PG_DB, nil, proxies, "html", locale, region))["contentHtml"]
|
comment_html = JSON.parse(fetch_youtube_comments(id, PG_DB, nil, proxies, "html", locale, preferences.thin_mode, region))["contentHtml"]
|
||||||
end
|
end
|
||||||
|
|
||||||
comment_html ||= ""
|
comment_html ||= ""
|
||||||
@ -447,9 +445,7 @@ get "/embed/:id" do |env|
|
|||||||
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
||||||
id = env.params.url["id"]
|
id = env.params.url["id"]
|
||||||
|
|
||||||
if env.get? "preferences"
|
preferences = env.get("preferences").as(Preferences)
|
||||||
preferences = env.get("preferences").as(Preferences)
|
|
||||||
end
|
|
||||||
|
|
||||||
if id.includes?("%20") || id.includes?("+") || env.params.query.to_s.includes?("%20") || env.params.query.to_s.includes?("+")
|
if id.includes?("%20") || id.includes?("+") || env.params.query.to_s.includes?("%20") || env.params.query.to_s.includes?("+")
|
||||||
id = env.params.url["id"].gsub("%20", "").delete("+")
|
id = env.params.url["id"].gsub("%20", "").delete("+")
|
||||||
@ -2682,6 +2678,9 @@ get "/api/v1/comments/:id" do |env|
|
|||||||
source = env.params.query["source"]?
|
source = env.params.query["source"]?
|
||||||
source ||= "youtube"
|
source ||= "youtube"
|
||||||
|
|
||||||
|
thin_mode = env.params.query["thin_mode"]?
|
||||||
|
thin_mode = thin_mode == "true"
|
||||||
|
|
||||||
format = env.params.query["format"]?
|
format = env.params.query["format"]?
|
||||||
format ||= "json"
|
format ||= "json"
|
||||||
|
|
||||||
@ -2689,7 +2688,7 @@ get "/api/v1/comments/:id" do |env|
|
|||||||
|
|
||||||
if source == "youtube"
|
if source == "youtube"
|
||||||
begin
|
begin
|
||||||
comments = fetch_youtube_comments(id, PG_DB, continuation, proxies, format, locale, region)
|
comments = fetch_youtube_comments(id, PG_DB, continuation, proxies, format, locale, thin_mode, region)
|
||||||
rescue ex
|
rescue ex
|
||||||
error_message = {"error" => ex.message}.to_json
|
error_message = {"error" => ex.message}.to_json
|
||||||
env.response.status_code = 500
|
env.response.status_code = 500
|
||||||
|
@ -56,7 +56,7 @@ class RedditListing
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_youtube_comments(id, db, continuation, proxies, format, locale, region)
|
def fetch_youtube_comments(id, db, continuation, proxies, format, locale, thin_mode, region)
|
||||||
video = get_video(id, db, proxies, region: region)
|
video = get_video(id, db, proxies, region: region)
|
||||||
|
|
||||||
session_token = video.info["session_token"]?
|
session_token = video.info["session_token"]?
|
||||||
@ -232,7 +232,7 @@ def fetch_youtube_comments(id, db, continuation, proxies, format, locale, region
|
|||||||
|
|
||||||
if format == "html"
|
if format == "html"
|
||||||
comments = JSON.parse(comments)
|
comments = JSON.parse(comments)
|
||||||
content_html = template_youtube_comments(comments, locale)
|
content_html = template_youtube_comments(comments, locale, thin_mode)
|
||||||
|
|
||||||
comments = JSON.build do |json|
|
comments = JSON.build do |json|
|
||||||
json.object do
|
json.object do
|
||||||
@ -278,7 +278,7 @@ def fetch_reddit_comments(id)
|
|||||||
return comments, thread
|
return comments, thread
|
||||||
end
|
end
|
||||||
|
|
||||||
def template_youtube_comments(comments, locale)
|
def template_youtube_comments(comments, locale, thin_mode)
|
||||||
html = ""
|
html = ""
|
||||||
|
|
||||||
root = comments["comments"].as_a
|
root = comments["comments"].as_a
|
||||||
@ -297,7 +297,11 @@ def template_youtube_comments(comments, locale)
|
|||||||
END_HTML
|
END_HTML
|
||||||
end
|
end
|
||||||
|
|
||||||
author_thumbnail = "/ggpht#{URI.parse(child["authorThumbnails"][-1]["url"].as_s).full_path}"
|
if !thin_mode
|
||||||
|
author_thumbnail = "/ggpht#{URI.parse(child["authorThumbnails"][-1]["url"].as_s).full_path}"
|
||||||
|
else
|
||||||
|
author_thumbnail = ""
|
||||||
|
end
|
||||||
|
|
||||||
html += <<-END_HTML
|
html += <<-END_HTML
|
||||||
<div class="pure-g">
|
<div class="pure-g">
|
||||||
@ -318,7 +322,12 @@ def template_youtube_comments(comments, locale)
|
|||||||
END_HTML
|
END_HTML
|
||||||
|
|
||||||
if child["creatorHeart"]?
|
if child["creatorHeart"]?
|
||||||
creator_thumbnail = "/ggpht#{URI.parse(child["creatorHeart"]["creatorThumbnail"].as_s).full_path}"
|
if !thin_mode
|
||||||
|
creator_thumbnail = "/ggpht#{URI.parse(child["creatorHeart"]["creatorThumbnail"].as_s).full_path}"
|
||||||
|
else
|
||||||
|
creator_thumbnail = ""
|
||||||
|
end
|
||||||
|
|
||||||
html += <<-END_HTML
|
html += <<-END_HTML
|
||||||
<span class="creator-heart-container" title="#{translate(locale, "`x` marked it with a ❤", child["creatorHeart"]["creatorName"].as_s)}">
|
<span class="creator-heart-container" title="#{translate(locale, "`x` marked it with a ❤", child["creatorHeart"]["creatorName"].as_s)}">
|
||||||
<div class="creator-heart">
|
<div class="creator-heart">
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<% case item when %>
|
<% case item when %>
|
||||||
<% when SearchChannel %>
|
<% when SearchChannel %>
|
||||||
<a style="width:100%;" href="/channel/<%= item.ucid %>">
|
<a style="width:100%;" href="/channel/<%= item.ucid %>">
|
||||||
<% if env.get?("user") && env.get("user").as(User).preferences.thin_mode %>
|
<% if env.get("preferences").as(Preferences).thin_mode %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<center>
|
<center>
|
||||||
<img style="width:56.25%;" src="/ggpht<%= URI.parse(item.author_thumbnail).full_path %>"/>
|
<img style="width:56.25%;" src="/ggpht<%= URI.parse(item.author_thumbnail).full_path %>"/>
|
||||||
@ -21,7 +21,7 @@
|
|||||||
<% url = "/playlist?list=#{item.id}" %>
|
<% url = "/playlist?list=#{item.id}" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<a style="width:100%;" href="<%= url %>">
|
<a style="width:100%;" href="<%= url %>">
|
||||||
<% if env.get?("user") && env.get("user").as(User).preferences.thin_mode %>
|
<% if env.get("preferences").as(Preferences).thin_mode %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="thumbnail">
|
<div class="thumbnail">
|
||||||
<img class="thumbnail" src="/vi/<%= item.thumbnail_id %>/mqdefault.jpg"/>
|
<img class="thumbnail" src="/vi/<%= item.thumbnail_id %>/mqdefault.jpg"/>
|
||||||
@ -35,7 +35,7 @@
|
|||||||
</p>
|
</p>
|
||||||
<% when MixVideo %>
|
<% when MixVideo %>
|
||||||
<a style="width:100%;" href="/watch?v=<%= item.id %>&list=<%= item.mixes[0] %>">
|
<a style="width:100%;" href="/watch?v=<%= item.id %>&list=<%= item.mixes[0] %>">
|
||||||
<% if env.get?("user") && env.get("user").as(User).preferences.thin_mode %>
|
<% if env.get("preferences").as(Preferences).thin_mode %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="thumbnail">
|
<div class="thumbnail">
|
||||||
<img class="thumbnail" src="/vi/<%= item.id %>/mqdefault.jpg"/>
|
<img class="thumbnail" src="/vi/<%= item.id %>/mqdefault.jpg"/>
|
||||||
@ -51,7 +51,7 @@
|
|||||||
</p>
|
</p>
|
||||||
<% when PlaylistVideo %>
|
<% when PlaylistVideo %>
|
||||||
<a style="width:100%;" href="/watch?v=<%= item.id %>&list=<%= item.playlists[0] %>">
|
<a style="width:100%;" href="/watch?v=<%= item.id %>&list=<%= item.playlists[0] %>">
|
||||||
<% if env.get?("user") && env.get("user").as(User).preferences.thin_mode %>
|
<% if env.get("preferences").as(Preferences).thin_mode %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="thumbnail">
|
<div class="thumbnail">
|
||||||
<img class="thumbnail" src="/vi/<%= item.id %>/mqdefault.jpg"/>
|
<img class="thumbnail" src="/vi/<%= item.id %>/mqdefault.jpg"/>
|
||||||
@ -74,7 +74,7 @@
|
|||||||
<h5><%= translate(locale, "Shared `x` ago", recode_date(item.published, locale)) %></h5>
|
<h5><%= translate(locale, "Shared `x` ago", recode_date(item.published, locale)) %></h5>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<% if env.get?("user") && env.get("user").as(User).preferences.thin_mode %>
|
<% if env.get("preferences").as(Preferences).thin_mode %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<a style="width:100%;" href="/watch?v=<%= item.id %>">
|
<a style="width:100%;" href="/watch?v=<%= item.id %>">
|
||||||
<div class="thumbnail">
|
<div class="thumbnail">
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<div class="pure-u-1 pure-u-md-1-4">
|
<div class="pure-u-1 pure-u-md-1-4">
|
||||||
<div class="h-box">
|
<div class="h-box">
|
||||||
<a style="width:100%;" href="/watch?v=<%= item %>">
|
<a style="width:100%;" href="/watch?v=<%= item %>">
|
||||||
<% if env.get?("user") && env.get("user").as(User).preferences.thin_mode %>
|
<% if env.get("preferences").as(Preferences).thin_mode %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="thumbnail">
|
<div class="thumbnail">
|
||||||
<img class="thumbnail" src="/vi/<%= item %>/mqdefault.jpg"/>
|
<img class="thumbnail" src="/vi/<%= item %>/mqdefault.jpg"/>
|
||||||
|
@ -167,7 +167,7 @@
|
|||||||
<% rvs.each do |rv| %>
|
<% rvs.each do |rv| %>
|
||||||
<% if rv["id"]? %>
|
<% if rv["id"]? %>
|
||||||
<a href="/watch?v=<%= rv["id"] %>">
|
<a href="/watch?v=<%= rv["id"] %>">
|
||||||
<% if preferences && preferences.thin_mode %>
|
<% if env.get("preferences").as(Preferences).thin_mode %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="thumbnail">
|
<div class="thumbnail">
|
||||||
<img class="thumbnail" src="/vi/<%= rv["id"] %>/mqdefault.jpg">
|
<img class="thumbnail" src="/vi/<%= rv["id"] %>/mqdefault.jpg">
|
||||||
@ -387,7 +387,7 @@ function get_youtube_comments(timeouts = 0) {
|
|||||||
comments.innerHTML =
|
comments.innerHTML =
|
||||||
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
|
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
|
||||||
|
|
||||||
var url = "/api/v1/comments/<%= video.id %>?format=html&hl=<%= env.get("preferences").as(Preferences).locale %>";
|
var url = "/api/v1/comments/<%= video.id %>?format=html&hl=<%= env.get("preferences").as(Preferences).locale %>&thin_mode=<%= env.get("preferences").as(Preferences).thin_mode %>";
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.responseType = "json";
|
xhr.responseType = "json";
|
||||||
xhr.timeout = 20000;
|
xhr.timeout = 20000;
|
||||||
@ -445,7 +445,7 @@ function get_youtube_replies(target, load_more) {
|
|||||||
body.innerHTML =
|
body.innerHTML =
|
||||||
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
|
'<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
|
||||||
|
|
||||||
var url = '/api/v1/comments/<%= video.id %>?format=html&hl=<%= env.get("preferences").as(Preferences).locale %>&continuation=' +
|
var url = '/api/v1/comments/<%= video.id %>?format=html&hl=<%= env.get("preferences").as(Preferences).locale %>&thin_mode=<%= env.get("preferences").as(Preferences).thin_mode %>&continuation=' +
|
||||||
continuation;
|
continuation;
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.responseType = 'json';
|
xhr.responseType = 'json';
|
||||||
|
Loading…
Reference in New Issue
Block a user