mirror of https://github.com/iv-org/invidious.git
Add support for default channel banners
This commit is contained in:
parent
556d5b0ca5
commit
48ad744ebf
|
@ -3565,6 +3565,7 @@ get "/api/v1/channels/:ucid" do |env|
|
||||||
|
|
||||||
json.field "authorBanners" do
|
json.field "authorBanners" do
|
||||||
json.array do
|
json.array do
|
||||||
|
if channel.banner
|
||||||
qualities = {
|
qualities = {
|
||||||
{width: 2560, height: 424},
|
{width: 2560, height: 424},
|
||||||
{width: 2120, height: 351},
|
{width: 2120, height: 351},
|
||||||
|
@ -3572,19 +3573,20 @@ get "/api/v1/channels/:ucid" do |env|
|
||||||
}
|
}
|
||||||
qualities.each do |quality|
|
qualities.each do |quality|
|
||||||
json.object do
|
json.object do
|
||||||
json.field "url", channel.banner.gsub("=w1060", "=w#{quality[:width]}")
|
json.field "url", channel.banner.not_nil!.gsub("=w1060", "=w#{quality[:width]}")
|
||||||
json.field "width", quality[:width]
|
json.field "width", quality[:width]
|
||||||
json.field "height", quality[:height]
|
json.field "height", quality[:height]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
json.object do
|
json.object do
|
||||||
json.field "url", channel.banner.rchop("=w1060-fcrop64=1,00005a57ffffa5a8-nd-c0xffffffff-rj-k-no")
|
json.field "url", channel.banner.not_nil!.rchop("=w1060-fcrop64=1,00005a57ffffa5a8-nd-c0xffffffff-rj-k-no")
|
||||||
json.field "width", 512
|
json.field "width", 512
|
||||||
json.field "height", 288
|
json.field "height", 288
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
json.field "authorThumbnails" do
|
json.field "authorThumbnails" do
|
||||||
json.array do
|
json.array do
|
||||||
|
@ -3592,7 +3594,7 @@ get "/api/v1/channels/:ucid" do |env|
|
||||||
|
|
||||||
qualities.each do |quality|
|
qualities.each do |quality|
|
||||||
json.object do
|
json.object do
|
||||||
json.field "url", channel.author_thumbnail.gsub("/s100-", "/s#{quality}-")
|
json.field "url", channel.author_thumbnail.gsub("=s100-", "=s#{quality}-")
|
||||||
json.field "width", quality
|
json.field "width", quality
|
||||||
json.field "height", quality
|
json.field "height", quality
|
||||||
end
|
end
|
||||||
|
|
|
@ -114,7 +114,7 @@ struct AboutChannel
|
||||||
auto_generated: Bool,
|
auto_generated: Bool,
|
||||||
author_url: String,
|
author_url: String,
|
||||||
author_thumbnail: String,
|
author_thumbnail: String,
|
||||||
banner: String,
|
banner: String?,
|
||||||
description_html: String,
|
description_html: String,
|
||||||
paid: Bool,
|
paid: Bool,
|
||||||
total_views: Int64,
|
total_views: Int64,
|
||||||
|
@ -654,6 +654,10 @@ def get_about_info(ucid, locale)
|
||||||
banner = about.xpath_node(%q(//div[@id="gh-banner"]/style)).not_nil!.content
|
banner = about.xpath_node(%q(//div[@id="gh-banner"]/style)).not_nil!.content
|
||||||
banner = "https:" + banner.match(/background-image: url\((?<url>[^)]+)\)/).not_nil!["url"]
|
banner = "https:" + banner.match(/background-image: url\((?<url>[^)]+)\)/).not_nil!["url"]
|
||||||
|
|
||||||
|
if banner.includes? "channels/c4/default_banner"
|
||||||
|
banner = nil
|
||||||
|
end
|
||||||
|
|
||||||
description_html = about.xpath_node(%q(//div[contains(@class,"about-description")])).try &.to_s || ""
|
description_html = about.xpath_node(%q(//div[contains(@class,"about-description")])).try &.to_s || ""
|
||||||
|
|
||||||
paid = about.xpath_node(%q(//meta[@itemprop="paid"])).not_nil!["content"] == "True"
|
paid = about.xpath_node(%q(//meta[@itemprop="paid"])).not_nil!["content"] == "True"
|
||||||
|
|
|
@ -3,13 +3,15 @@
|
||||||
<link rel="alternate" type="application/rss+xml" title="RSS" href="/feed/channel/<%= channel.ucid %>" />
|
<link rel="alternate" type="application/rss+xml" title="RSS" href="/feed/channel/<%= channel.ucid %>" />
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% if channel.banner %>
|
||||||
<div class="h-box">
|
<div class="h-box">
|
||||||
<img style="width:100%" src="/ggpht<%= URI.parse(channel.banner.gsub("=w1060", "=w1280")).full_path %>">
|
<img style="width:100%" src="/ggpht<%= URI.parse(channel.banner.not_nil!.gsub("=w1060", "=w1280")).full_path %>">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="h-box">
|
<div class="h-box">
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<div class="pure-g h-box">
|
<div class="pure-g h-box">
|
||||||
<div class="pure-u-2-3">
|
<div class="pure-u-2-3">
|
||||||
|
|
|
@ -2,13 +2,15 @@
|
||||||
<title><%= channel.author %> - Invidious</title>
|
<title><%= channel.author %> - Invidious</title>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% if channel.banner %>
|
||||||
<div class="h-box">
|
<div class="h-box">
|
||||||
<img style="width:100%" src="/ggpht<%= URI.parse(channel.banner.gsub("=w1060", "=w1280")).full_path %>">
|
<img style="width:100%" src="/ggpht<%= URI.parse(channel.banner.not_nil!.gsub("=w1060", "=w1280")).full_path %>">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="h-box">
|
<div class="h-box">
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<div class="pure-g h-box">
|
<div class="pure-g h-box">
|
||||||
<div class="pure-u-2-3">
|
<div class="pure-u-2-3">
|
||||||
|
|
Loading…
Reference in New Issue