mirror of
				https://github.com/iv-org/invidious.git
				synced 2025-11-04 14:41:59 +00:00 
			
		
		
		
	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:
		@@ -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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user