invidious icon indicating copy to clipboard operation
invidious copied to clipboard

API: Check if playlist has any videos on it.

Open Fijxu opened this issue 9 months ago • 1 comments

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 fixes this API endpoints when there is no videos in a playlist:

api/v1/playlists/:plid
api/v1/auth/playlists/:plid

For some weird reason, the api/v1/auth/playlists/:plid endpoint was able the return the error Index out of bounds as said in #4679 but api/v1/playlists/:plid did not return anything. Weird

Fixes #4679

Fijxu avatar May 14 '24 01:05 Fijxu

Can be tested with a empty playlist that I created at https://debuginv.nadeko.net/api/v1/playlists/PL5ASK6Z87scO0GrGbMzxVz5qvMhRUitbG

Fijxu avatar May 14 '24 01:05 Fijxu

For some weird reason, the api/v1/auth/playlists/:plid endpoint was able the return the error Index out of bounds as said in #4679 but api/v1/playlists/:plid did not return anything. Weird

This because the authentication middleware (AuthHandler) catches the error and displays it nicely: https://github.com/iv-org/invidious/blob/bad92093bff66bfb0281e5276fa0e136a61ba330/src/invidious/helpers/handlers.cr#L127-L133

SamantazFox avatar Jul 20 '24 15:07 SamantazFox

Thank you for fixing this :)

SamantazFox avatar Jul 21 '24 15:07 SamantazFox