Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: list index out of range #45

Open
mooseyoose opened this issue Nov 7, 2020 · 6 comments
Open

IndexError: list index out of range #45

mooseyoose opened this issue Nov 7, 2020 · 6 comments

Comments

@mooseyoose
Copy link

Hi,

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

@CosmicHorrorDev
Copy link

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 of 366876694 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.

@mooseyoose
Copy link
Author

Thanks! I managed to get it working. I wasn't using the size variable properly.

I'm trying to get subtitles for the movie Joker 2019. But it's only returning 1 subtitle. Any idea why it can only find 1?

@CosmicHorrorDev
Copy link

CosmicHorrorDev commented Nov 7, 2020

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:

ost.search_subtitles([{"query": "Joker 2019"}])

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.

@mooseyoose
Copy link
Author

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:

ost.search_subtitles([{"query": "Joker 2019"}])

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.

Sorry for the late reply. Your answer has been helpful and I've got it working. Do you know how to increase the limit from 5 in the API?

@CosmicHorrorDev
Copy link

It's listed here. Searches are limited to 5 results on the testing user agent which is the one that this library sets unless you provide a different value. I think 5 results are good enough for most people though, particularly when you are doing an exact file match. If you want more than 5 results you would have to register for your own user agent.

@CosmicHorrorDev
Copy link

If you want to keep asking questions then feel free to email me (It's listed under my profile). I'd rather not keep this thread going since the original issue was resolved since it can create noise for other people to sift through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants