API: Check if playlist has any videos on it.
Invidious assumes that every playlist will have at least one video because it needs to check for the `index` key. So if there is no videos on a playlist, there is no `index` key and Invidious throws `Index out of bounds`
This commit is contained in:
parent
eda7444ca4
commit
e0d0dbde3c
|
@ -74,7 +74,9 @@ module Invidious::Routes::API::V1::Misc
|
|||
response = playlist.to_json(offset, video_id: video_id)
|
||||
json_response = JSON.parse(response)
|
||||
|
||||
if json_response["videos"].as_a[0]["index"] != offset
|
||||
if json_response["videos"].as_a.empty?
|
||||
json_response = JSON.parse(response)
|
||||
elsif json_response["videos"].as_a[0]["index"] != offset
|
||||
offset = json_response["videos"].as_a[0]["index"].as_i
|
||||
lookback = offset < 50 ? offset : 50
|
||||
response = playlist.to_json(offset - lookback)
|
||||
|
|
Loading…
Reference in a new issue