youtube_api icon indicating copy to clipboard operation
youtube_api copied to clipboard

Index out of range error

Open pmpBear opened this issue 4 years ago • 1 comments

I had a problem with your plugin today. Suddenly it stopped working returning an error about an index out of range.

I've figured out that the problem is that the YT api value "total results" returns an approximation, therefore you can't use it as the max value of a for loop.

Check the documentation here: https://developers.google.com/youtube/v3/docs/search/list

In my case I had 13 videos, but the total results value was 14.

So, in your plugin you should replace all the occurrences of jsonData['pageInfo']['totalResults'] with Jason data['items'].length

Hope this helps!

pmpBear avatar Oct 09 '20 19:10 pmpBear