mirror of
https://github.com/iv-org/invidious.git
synced 2025-07-29 00:38:30 +00:00
Add logic to search nextContinuationData for token
This commit is contained in:
parent
8e3966fa86
commit
74cab85fd4
@ -102,9 +102,21 @@ def extract_video_info(video_id : String, proxy_region : String? = nil)
|
|||||||
|
|
||||||
# Workaround for #4415
|
# Workaround for #4415
|
||||||
if params["relatedVideos"].as_a.empty?
|
if params["relatedVideos"].as_a.empty?
|
||||||
continuation = player_response.dig?("contents", "twoColumnWatchNextResults", "secondaryResults",
|
secondary_results = player_response.dig?("contents", "twoColumnWatchNextResults", "secondaryResults", "secondaryResults")
|
||||||
"secondaryResults", "results", 0, "continuationItemRenderer",
|
|
||||||
"continuationEndpoint", "continuationCommand", "token")
|
if secondary_results
|
||||||
|
# The continuation token can be in either continuationItemRenderer or a nextContinuationData object
|
||||||
|
continuation_renderer = secondary_results["results"].as_a.find(&.dig?("continuationItemRenderer"))
|
||||||
|
|
||||||
|
continuation = continuation_renderer.try &.["continuationItemRenderer"].dig?(
|
||||||
|
"onResponseReceivedEndpoints", 0, "appendContinuationItemsAction", "continuationItems"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Try to parse the continuation token from the nextContinuationData object
|
||||||
|
if !continuation
|
||||||
|
next_continuation_data_container = secondary_results.dig?("continuations").try &.as_a.find(&.["nextContinuationData"]?)
|
||||||
|
continuation = next_continuation_data_container.try &.dig?("nextContinuationData", "continuation")
|
||||||
|
end
|
||||||
|
|
||||||
if continuation
|
if continuation
|
||||||
raw_related_videos = YoutubeAPI.next(continuation: continuation.as_s)
|
raw_related_videos = YoutubeAPI.next(continuation: continuation.as_s)
|
||||||
@ -122,6 +134,7 @@ def extract_video_info(video_id : String, proxy_region : String? = nil)
|
|||||||
params["relatedVideos"] = JSON::Any.new(related)
|
params["relatedVideos"] = JSON::Any.new(related)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
new_player_response = nil
|
new_player_response = nil
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user