From e7366269535368a33598e49c1844da21c97522ba Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Sat, 20 Jul 2019 11:38:20 -0500 Subject: [PATCH] Fix continuation for last page of playlists --- src/invidious/channels.cr | 13 +++++++------ src/invidious/views/playlists.ecr | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/invidious/channels.cr b/src/invidious/channels.cr index 0bbd0eaa..129ff192 100644 --- a/src/invidious/channels.cr +++ b/src/invidious/channels.cr @@ -375,13 +375,14 @@ def fetch_channel_playlists(ucid, author, auto_generated, continuation, sort_by) json = JSON.parse(response.body) if json["load_more_widget_html"].as_s.empty? - return [] of SearchItem, nil - end + continuation = nil + else + continuation = XML.parse_html(json["load_more_widget_html"].as_s) + continuation = continuation.xpath_node(%q(//button[@data-uix-load-more-href])) - continuation = XML.parse_html(json["load_more_widget_html"].as_s) - continuation = continuation.xpath_node(%q(//button[@data-uix-load-more-href])) - if continuation - continuation = extract_channel_playlists_cursor(continuation["data-uix-load-more-href"], auto_generated) + if continuation + continuation = extract_channel_playlists_cursor(continuation["data-uix-load-more-href"], auto_generated) + end end html = XML.parse_html(json["content_html"].as_s) diff --git a/src/invidious/views/playlists.ecr b/src/invidious/views/playlists.ecr index 0a5a0c13..1825bb48 100644 --- a/src/invidious/views/playlists.ecr +++ b/src/invidious/views/playlists.ecr @@ -85,7 +85,7 @@
- <% if items.size >= 28 %> + <% if continuation %> &sort_by=<%= sort_by %><% end %>"> <%= translate(locale, "Next page") %>