mirror of
https://github.com/iv-org/invidious
synced 2024-11-28 14:03:28 +01:00
Bump number of videos in channel resources to 60
This commit is contained in:
parent
d81a803618
commit
b17d3d1e51
104
src/invidious.cr
104
src/invidious.cr
@ -1407,21 +1407,26 @@ get "/feed/channel/:ucid" do |env|
|
||||
auto_generated = true
|
||||
end
|
||||
|
||||
url = produce_channel_videos_url(ucid, auto_generated: auto_generated)
|
||||
response = client.get(url)
|
||||
json = JSON.parse(response.body)
|
||||
page = 1
|
||||
|
||||
if json["content_html"]? && !json["content_html"].as_s.empty?
|
||||
document = XML.parse_html(json["content_html"].as_s)
|
||||
nodeset = document.xpath_nodes(%q(//li[contains(@class, "feed-item-container")]))
|
||||
videos = [] of SearchVideo
|
||||
2.times do |i|
|
||||
url = produce_channel_videos_url(ucid, page * 2 + (i - 1), auto_generated: auto_generated)
|
||||
response = client.get(url)
|
||||
json = JSON.parse(response.body)
|
||||
|
||||
if auto_generated
|
||||
videos = extract_videos(nodeset)
|
||||
if json["content_html"]? && !json["content_html"].as_s.empty?
|
||||
document = XML.parse_html(json["content_html"].as_s)
|
||||
nodeset = document.xpath_nodes(%q(//li[contains(@class, "feed-item-container")]))
|
||||
|
||||
if auto_generated
|
||||
videos += extract_videos(nodeset)
|
||||
else
|
||||
videos += extract_videos(nodeset, ucid)
|
||||
end
|
||||
else
|
||||
videos = extract_videos(nodeset, ucid)
|
||||
break
|
||||
end
|
||||
else
|
||||
videos = [] of SearchVideo
|
||||
end
|
||||
|
||||
channel = get_channel(ucid, client, PG_DB, pull_all_videos: false)
|
||||
@ -1659,21 +1664,24 @@ get "/channel/:ucid" do |env|
|
||||
auto_generated = true
|
||||
end
|
||||
|
||||
url = produce_channel_videos_url(ucid, page, auto_generated: auto_generated)
|
||||
response = client.get(url)
|
||||
json = JSON.parse(response.body)
|
||||
videos = [] of SearchVideo
|
||||
2.times do |i|
|
||||
url = produce_channel_videos_url(ucid, page * 2 + (i - 1), auto_generated: auto_generated)
|
||||
response = client.get(url)
|
||||
json = JSON.parse(response.body)
|
||||
|
||||
if json["content_html"]? && !json["content_html"].as_s.empty?
|
||||
document = XML.parse_html(json["content_html"].as_s)
|
||||
nodeset = document.xpath_nodes(%q(//li[contains(@class, "feed-item-container")]))
|
||||
if json["content_html"]? && !json["content_html"].as_s.empty?
|
||||
document = XML.parse_html(json["content_html"].as_s)
|
||||
nodeset = document.xpath_nodes(%q(//li[contains(@class, "feed-item-container")]))
|
||||
|
||||
if auto_generated
|
||||
videos = extract_videos(nodeset)
|
||||
if auto_generated
|
||||
videos += extract_videos(nodeset)
|
||||
else
|
||||
videos += extract_videos(nodeset, ucid)
|
||||
end
|
||||
else
|
||||
videos = extract_videos(nodeset, ucid)
|
||||
break
|
||||
end
|
||||
else
|
||||
videos = [] of SearchVideo
|
||||
end
|
||||
|
||||
templated "channel"
|
||||
@ -2309,21 +2317,26 @@ get "/api/v1/channels/:ucid" do |env|
|
||||
auto_generated = true
|
||||
end
|
||||
|
||||
url = produce_channel_videos_url(ucid, 1, auto_generated)
|
||||
response = client.get(url)
|
||||
page = 1
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
if json["content_html"]? && !json["content_html"].as_s.empty?
|
||||
document = XML.parse_html(json["content_html"].as_s)
|
||||
nodeset = document.xpath_nodes(%q(//li[contains(@class, "feed-item-container")]))
|
||||
videos = [] of SearchVideo
|
||||
2.times do |i|
|
||||
url = produce_channel_videos_url(ucid, page * 2 + (i - 1), auto_generated: auto_generated)
|
||||
response = client.get(url)
|
||||
json = JSON.parse(response.body)
|
||||
|
||||
if auto_generated
|
||||
videos = extract_videos(nodeset)
|
||||
if json["content_html"]? && !json["content_html"].as_s.empty?
|
||||
document = XML.parse_html(json["content_html"].as_s)
|
||||
nodeset = document.xpath_nodes(%q(//li[contains(@class, "feed-item-container")]))
|
||||
|
||||
if auto_generated
|
||||
videos += extract_videos(nodeset)
|
||||
else
|
||||
videos += extract_videos(nodeset, ucid)
|
||||
end
|
||||
else
|
||||
videos = extract_videos(nodeset, ucid)
|
||||
break
|
||||
end
|
||||
else
|
||||
videos = [] of SearchVideo
|
||||
end
|
||||
|
||||
channel_html = client.get("/channel/#{ucid}/about?disable_polymer=1").body
|
||||
@ -2486,21 +2499,24 @@ get "/api/v1/channels/:ucid/videos" do |env|
|
||||
auto_generated = true
|
||||
end
|
||||
|
||||
url = produce_channel_videos_url(ucid, auto_generated: auto_generated)
|
||||
response = client.get(url)
|
||||
json = JSON.parse(response.body)
|
||||
videos = [] of SearchVideo
|
||||
2.times do |i|
|
||||
url = produce_channel_videos_url(ucid, page * 2 + (i - 1), auto_generated: auto_generated)
|
||||
response = client.get(url)
|
||||
json = JSON.parse(response.body)
|
||||
|
||||
if json["content_html"]? && !json["content_html"].as_s.empty?
|
||||
document = XML.parse_html(json["content_html"].as_s)
|
||||
nodeset = document.xpath_nodes(%q(//li[contains(@class, "feed-item-container")]))
|
||||
if json["content_html"]? && !json["content_html"].as_s.empty?
|
||||
document = XML.parse_html(json["content_html"].as_s)
|
||||
nodeset = document.xpath_nodes(%q(//li[contains(@class, "feed-item-container")]))
|
||||
|
||||
if auto_generated
|
||||
videos = extract_videos(nodeset)
|
||||
if auto_generated
|
||||
videos += extract_videos(nodeset)
|
||||
else
|
||||
videos += extract_videos(nodeset, ucid)
|
||||
end
|
||||
else
|
||||
videos = extract_videos(nodeset, ucid)
|
||||
break
|
||||
end
|
||||
else
|
||||
videos = [] of SearchVideo
|
||||
end
|
||||
|
||||
result = JSON.build do |json|
|
||||
|
@ -51,7 +51,7 @@
|
||||
</div>
|
||||
<div class="pure-u-1 pure-u-md-3-5"></div>
|
||||
<div style="text-align:right;" class="pure-u-1 pure-u-md-1-5">
|
||||
<% if videos.size == 30 %>
|
||||
<% if videos.size == 60 %>
|
||||
<a href="/channel/<%= ucid %>?page=<%= page + 1 %>">Next page</a>
|
||||
<% end %>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user