Bump number of videos in channel resources to 60

This commit is contained in:
Omar Roth 2018-09-06 08:43:22 -05:00
parent d81a803618
commit b17d3d1e51
2 changed files with 61 additions and 45 deletions

View file

@ -1407,7 +1407,11 @@ get "/feed/channel/:ucid" do |env|
auto_generated = true
end
url = produce_channel_videos_url(ucid, auto_generated: auto_generated)
page = 1
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)
@ -1416,12 +1420,13 @@ get "/feed/channel/:ucid" do |env|
nodeset = document.xpath_nodes(%q(//li[contains(@class, "feed-item-container")]))
if auto_generated
videos = extract_videos(nodeset)
videos += extract_videos(nodeset)
else
videos = extract_videos(nodeset, ucid)
videos += extract_videos(nodeset, ucid)
end
else
videos = [] of SearchVideo
break
end
end
channel = get_channel(ucid, client, PG_DB, pull_all_videos: false)
@ -1659,7 +1664,9 @@ get "/channel/:ucid" do |env|
auto_generated = true
end
url = produce_channel_videos_url(ucid, page, auto_generated: auto_generated)
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)
@ -1668,12 +1675,13 @@ get "/channel/:ucid" do |env|
nodeset = document.xpath_nodes(%q(//li[contains(@class, "feed-item-container")]))
if auto_generated
videos = extract_videos(nodeset)
videos += extract_videos(nodeset)
else
videos = extract_videos(nodeset, ucid)
videos += extract_videos(nodeset, ucid)
end
else
videos = [] of SearchVideo
break
end
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
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 auto_generated
videos = extract_videos(nodeset)
videos += extract_videos(nodeset)
else
videos = extract_videos(nodeset, ucid)
videos += extract_videos(nodeset, ucid)
end
else
videos = [] of SearchVideo
break
end
end
channel_html = client.get("/channel/#{ucid}/about?disable_polymer=1").body
@ -2486,7 +2499,9 @@ get "/api/v1/channels/:ucid/videos" do |env|
auto_generated = true
end
url = produce_channel_videos_url(ucid, auto_generated: auto_generated)
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)
@ -2495,12 +2510,13 @@ get "/api/v1/channels/:ucid/videos" do |env|
nodeset = document.xpath_nodes(%q(//li[contains(@class, "feed-item-container")]))
if auto_generated
videos = extract_videos(nodeset)
videos += extract_videos(nodeset)
else
videos = extract_videos(nodeset, ucid)
videos += extract_videos(nodeset, ucid)
end
else
videos = [] of SearchVideo
break
end
end
result = JSON.build do |json|

View file

@ -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>