IndexError: list index out of range
See original GitHub issueHi,
When I use the example provided, I get this error:
Traceback (most recent call last): File "subtitles.py", line 10, in <module> id_subtitle_file = data[0].get('IDSubtitleFile') IndexError: list index out of range
Any idea?
Thanks
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
List Index Out of Range – Python Error Message Solved
You'll get the Indexerror: list index out of range error when iterating through a list and trying to access an item that doesn't...
Read more >Indexerror: list Index Out of Range in Python - STechies
In python “list index out of range” error occurs when we try to access an undefined element from the list. List index out...
Read more >Index Error: list index out of range (Python) - Stack Overflow
Generally it means that you are providing an index for which a list element does not exist. E.g, if your list was [1,...
Read more >Python IndexError: List Index Out of Range [Easy Fix] - Finxter
The error “list index out of range” arises if you access invalid indices in your ...
Read more >How to fix - List Index Out of Range in Python - GeeksforGeeks
Reason of the error – The length of the list is 5 and if we are an iterating list on 6 then it...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If you’re doing a search by an exact match then it’s very possible that there is only one set of subtitles associated with that exact file (the api does limit to 5 results per query if you’re using the default user agent, although I can’t find the docs on that now). You could also try doing a full-text search with something like:
Although this won’t be as accurate as the exact match since the subtitles might not be aligned, or it may get some wrong results.
Like I mentioned before this library is a very thin wrapper, so the only reason I know these things is from opensubtitles’ documentation, since I’ve been working on my own wrapper.
From what I can tell it looks like the search didn’t return any items for your query, but didn’t raise an error (which might be for a number of reasons. I don’t remember how the api handles malformed queries).
If you try the query with a hash of
"18379ac9af039390"
, and a size of366876694
then you should get responses for fringe season 4 episode 3 if that helps you debug. This library provides a very thin wrapper in most cases so its easy to mistype the queries.It’s possible whatever you are trying to query for just returned no results as well.