0

I'm using the python library for Youtube API v3 and I'm trying to retrieve the name of the author of the last reply on a specific thread.

Right now I'm doing the following:

video_comments = get_comments(youtube,'thread_ID')

print video_comments[0]['snippet']['authorDisplayName']

The get_comments function is from their own example and I have an infinite loop that keeps looking this up. However every now and then I am getting this error:

IndexError: list index out of range

Any suggestions on what's causing this and how I can fix it?

Silver
  • 1,327
  • 12
  • 24
  • does the video have any comments? – TZHX Sep 28 '16 at 14:33
  • In the hundreds. Basically I'm trying to do a live lookup if there's any new comments added by someone other than me. – Silver Sep 28 '16 at 14:33
  • From this [thread](https://docs.python.org/2/library/exceptions.html#exceptions.IndexError), the exception IndexError is raised when a sequence subscript is out of range. (Slice indices are silently truncated to fall in the allowed range; if an index is not a plain integer, TypeError is raised.) For another explanation for that error, check these related SO questions [9256013](http://stackoverflow.com/questions/9256013/python-indexerror-list-index-out-of-range) and [1098643](http://stackoverflow.com/questions/1098643/indexerror-list-index-out-of-range-and-python) – KENdi Sep 29 '16 at 15:22

0 Answers0