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
|
end
|
||||||
|
|
||||||
def fetch_continuation_token(initial_data : Hash(String, JSON::Any))
|
def fetch_continuation_token(initial_data : Hash(String, JSON::Any))
|
||||||
|
continuation = ""
|
||||||
# Fetches the continuation token from initial data
|
# Fetches the continuation token from initial data
|
||||||
if initial_data["onResponseReceivedActions"]?
|
if initial_data["onResponseReceivedActions"]?
|
||||||
continuation_items = initial_data["onResponseReceivedActions"][0]["appendContinuationItemsAction"]["continuationItems"]
|
continuation_items = initial_data["onResponseReceivedActions"][0]["appendContinuationItemsAction"]["continuationItems"]
|
||||||
elsif initial_data["contents"]?
|
elsif initial_data["contents"]?
|
||||||
tab = extract_selected_tab(initial_data["contents"]["twoColumnBrowseResultsRenderer"]["tabs"])
|
tab = extract_selected_tab(initial_data["contents"]["twoColumnBrowseResultsRenderer"]["tabs"])
|
||||||
continuation_items = tab["content"]["sectionListRenderer"]["contents"][0]["itemSectionRenderer"]["contents"][0]["gridRenderer"]["items"]
|
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
|
continuation = initial_data["continuationContents"]["gridContinuation"]["continuations"][0]["nextContinuationData"]["continuation"].as_s
|
||||||
end
|
end
|
||||||
|
|
||||||
if continuation_items.nil?
|
if !continuation_items.nil?
|
||||||
return continuation
|
continuation = fetch_continuation_token(continuation_items.as_a)
|
||||||
else
|
|
||||||
return fetch_continuation_token(continuation_items.as_a)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return continuation
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue