Forum rules
Under no circumstances is spamming or advertising of any kind allowed. Do not post any abusive, obscene, vulgar, slanderous, hateful, threatening, sexually-orientated or any other material that may violate others security. Profanity or any kind of insolent behavior to other members (regardless of rank) will not be tolerated. Remember, what you don’t find offensive can be offensive to other members. Please treat each other with the kind of reverence you’d expect from other members.
Failure to comply with any of the above will result in users being banned without notice. If any further details are needed, contact: “The team” using the link at the bottom of the forum page. Thank you.
qacomohibeb
Posts: 2
Joined: Wed Apr 12, 2023 5:24 pm

Re: Open subtitles API download issue

Fri Apr 14, 2023 7:21 am

This seems to be the problem. Thanks.

However, note that the code examples show either Bearer or Key authorization.
E.g.

Code: Select all

curl --request POST \ --url https://api.opensubtitles.com/api/v1/download \ --header 'Authorization: Bearer xyz' \ --header 'Content-Type: application/json' \ --data '{ "file_id": 123 }'
and:

Code: Select all

curl --request POST \ --url https://api.opensubtitles.com/api/v1/download \ --header 'Api-Key: x' \ --header 'Content-Type: application/json' \ --data '{ "file_id": 123 }'

os_dev
Posts: 194
Joined: Wed Oct 17, 2018 3:42 pm

Re: Open subtitles API download issue

Fri Apr 14, 2023 9:49 am

This seems to be the problem. Thanks.

However, note that the code examples show either Bearer or Key authorization.
E.g.

Code: Select all

curl --request POST \ --url https://api.opensubtitles.com/api/v1/download \ --header 'Authorization: Bearer xyz' \ --header 'Content-Type: application/json' \ --data '{ "file_id": 123 }'
and:

Code: Select all

curl --request POST \ --url https://api.opensubtitles.com/api/v1/download \ --header 'Api-Key: x' \ --header 'Content-Type: application/json' \ --data '{ "file_id": 123 }'
So, in all documentation, the instructions take precedence over the examples. The documentation system generates the curl examples, and he won't let us put 2 authentication methods in the header.

that's why we put that message on top "In HTTP request must be both headers: Api-Key and Authorization"

User avatar
oss
Site Admin
Posts: 5879
Joined: Sat Feb 25, 2006 11:26 pm
Contact: Website

Re: Open subtitles API download issue

Fri Apr 14, 2023 6:15 pm

I will update documentation, that example on the right is not correct because limitations of stoplight.io

RazerBlader
Posts: 3
Joined: Sun Apr 16, 2023 5:42 am

Re: Open subtitles API download issue

Sun Apr 16, 2023 7:08 am

I've been struggling to successfully download files with the API, even with both 'Authorization' and 'API-Key' verification methods in the header. I'm working in python and am new to using API's, so my apologies if I'm making a silly error.

Here is the code I am using to try to connect and download a subtitle file from a subtitle id (in this case 1860215).

Code: Select all

import http.client conn = http.client.HTTPSConnection("api.opensubtitles.com") payload = "{\n \"file_id\": 1860215\n}" headers = { "Content-Type": "application/json", "Authorization": "Bearer {}", "Api-Key": "{}".format(api_key,api_key) } conn.request("POST", "/api/v1/download", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8"))
I've tried quite a lot of different ways of doing it, with different authentication methods and with requests instead of client, but nothing is working properly. I am currently getting this error: "message":"The upstream server is timing out".

Using the previous url https://www.opensubtitles.com/api/v1/login I've managed to get a script working, but it stops working after a set number of requests (I understand that this is intentional and is being depreciated).

Please can someone help me figure out what is going wrong. Many thanks!

User avatar
oss
Site Admin
Posts: 5879
Joined: Sat Feb 25, 2006 11:26 pm
Contact: Website

Re: Open subtitles API download issue

Sun Apr 16, 2023 3:34 pm

Hi

we are not python programmers, but here it seems you sending EMPTY Bearer ?

headers = { "Content-Type": "application/json", "Authorization": "Bearer {}", "Api-Key": "{}".format(api_key,api_key) }

the best way is to use INSOMNIA or POSTMAN - it is really good. Then you can send CURL examples, so I can just copy and paste it in terminal and it is more visible what actual data you are sending

API works, there are around 1000 requests per second to it right now.

RazerBlader
Posts: 3
Joined: Sun Apr 16, 2023 5:42 am

Re: Open subtitles API download issue

Mon Apr 17, 2023 6:09 am

Thanks for the info, played around with Postman and managed to find/fix the issue. I was using the Api-Key for both verification methods instead of using the JWT as the token.

User avatar
oss
Site Admin
Posts: 5879
Joined: Sat Feb 25, 2006 11:26 pm
Contact: Website

Re: Open subtitles API download issue

Wed Apr 19, 2023 3:10 pm

glad you solved it.

Return to “Developing”

Who is online

Users browsing this forum: No registered users and 33 guests