mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-08-14.git
synced 2024-08-15 00:53:20 +00:00
Fix fetching of large playlist
This commit is contained in:
parent
3286328de4
commit
fec82df451
1 changed files with 2 additions and 11 deletions
|
@ -441,17 +441,8 @@ def fetch_playlist_videos(plid, video_count, offset = 0, locale = nil, continuat
|
||||||
offset = initial_data["currentVideoEndpoint"]?.try &.["watchEndpoint"]?.try &.["index"]?.try &.as_i64 || offset
|
offset = initial_data["currentVideoEndpoint"]?.try &.["watchEndpoint"]?.try &.["index"]?.try &.as_i64 || offset
|
||||||
end
|
end
|
||||||
|
|
||||||
if video_count > 100
|
|
||||||
url = produce_playlist_url(plid, offset)
|
|
||||||
|
|
||||||
response = YT_POOL.client &.get(url)
|
|
||||||
initial_data = JSON.parse(response.body).as_a.find(&.as_h.["response"]?).try &.as_h
|
|
||||||
elsif offset > 100
|
|
||||||
return [] of PlaylistVideo
|
|
||||||
else # Extract first page of videos
|
|
||||||
response = YT_POOL.client &.get("/playlist?list=#{plid}&gl=US&hl=en")
|
response = YT_POOL.client &.get("/playlist?list=#{plid}&gl=US&hl=en")
|
||||||
initial_data = extract_initial_data(response.body)
|
initial_data = extract_initial_data(response.body)
|
||||||
end
|
|
||||||
|
|
||||||
return [] of PlaylistVideo if !initial_data
|
return [] of PlaylistVideo if !initial_data
|
||||||
videos = extract_playlist_videos(initial_data)
|
videos = extract_playlist_videos(initial_data)
|
||||||
|
|
Loading…
Reference in a new issue