mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-04-11.git
synced 2024-08-15 00:43:26 +00:00
Handle when there are no continuations returned due to being on the last page.
Also tidy up the return statements
This commit is contained in:
parent
f34f06bca5
commit
55fc6e7bbe
1 changed files with 6 additions and 5 deletions
|
@ -55,19 +55,20 @@ def fetch_continuation_token(items : Array(JSON::Any))
|
|||
end
|
||||
|
||||
def fetch_continuation_token(initial_data : Hash(String, JSON::Any))
|
||||
continuation = ""
|
||||
# Fetches the continuation token from initial data
|
||||
if initial_data["onResponseReceivedActions"]?
|
||||
continuation_items = initial_data["onResponseReceivedActions"][0]["appendContinuationItemsAction"]["continuationItems"]
|
||||
elsif initial_data["contents"]?
|
||||
tab = extract_selected_tab(initial_data["contents"]["twoColumnBrowseResultsRenderer"]["tabs"])
|
||||
continuation_items = tab["content"]["sectionListRenderer"]["contents"][0]["itemSectionRenderer"]["contents"][0]["gridRenderer"]["items"]
|
||||
else
|
||||
elsif initial_data["continuationContents"]["gridContinuation"]["continuations"]?
|
||||
continuation = initial_data["continuationContents"]["gridContinuation"]["continuations"][0]["nextContinuationData"]["continuation"].as_s
|
||||
end
|
||||
|
||||
if continuation_items.nil?
|
||||
return continuation
|
||||
else
|
||||
return fetch_continuation_token(continuation_items.as_a)
|
||||
if !continuation_items.nil?
|
||||
continuation = fetch_continuation_token(continuation_items.as_a)
|
||||
end
|
||||
|
||||
return continuation
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue