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!