Page 1 of 4

Open subtitles API download issue

Posted: Sun Sep 12, 2021 6:58 am
by kva1992
Hello,

I am trying to integrate open subtitles API to my app I am building for Android and everything is working fine except downloading the subtitles. At first I thought it might be an issue with the authorization token but I tested that out by making a get request for user info and it worked perfectly fine. So I can confirm passing the auth parameters is working properly. I keep getting an 406 error on the api test area. Any help would be appreciated. Thank you!

Re: Open subtitles API download issue

Posted: Sun Sep 12, 2021 7:59 am
by oss
Hi,

it is always good stating which API you are using first, I guess the new api.opensubtitles.com

it should work. That said - please send requests and response (you can PM me or mail me...) and we will try to help.

Re: Open subtitles API download issue

Posted: Sun Sep 12, 2021 8:33 am
by kva1992
Hi,

it is always good stating which API you are using first, I guess the new api.opensubtitles.com

it should work. That said - please send requests and response (you can PM me or mail me...) and we will try to help.
Sorry I forgot there was two APIs. But yeah I am using the api.opensubtitles.com this is where i am testing it.

https://opensubtitles.stoplight.io/docs ... nload/post

Under headers I am posting content-type as application/json, authorization and the token, the api-key and the api key.
body this is what i am posting

Code: Select all

{ "file_id":4486640, "sub_format": "string", "file_name": "string", "strip_html": true, "cleanup_links": true, "remove_adds": true, "in_fps": 0, "out_fps": 0, "timeshift": 0 }
ive also tried it with just

Code: Select all

{ "file_id":4486640 }
and still the same thing.

I get no response back just a 406 error.

If i do the same request in android I get a filenotfound error. Weird part is all the other api calls are working perfectly fine.

let me know if youd like me to post any other information. If needed I can post the android java httprequest and how i have it formatted and setup.

Re: Open subtitles API download issue

Posted: Sun Sep 12, 2021 2:32 pm
by os_dev

ive also tried it with just

Code: Select all

{ "file_id":4486640 }
and still the same thing.

I get no response back just a 406 error.

If i do the same request in android I get a filenotfound error. Weird part is all the other api calls are working perfectly fine.

let me know if youd like me to post any other information. If needed I can post the android java httprequest and how i have it formatted and setup.
Did you try this with an app such as postman or insomnia ? I get no error with that file...

no need to track too far in your code implementation, it is important we work in a similar environment so I can replicate the errors you may find.

Re: Open subtitles API download issue

Posted: Sun Sep 12, 2021 5:32 pm
by kva1992

ive also tried it with just

Code: Select all

{ "file_id":4486640 }
and still the same thing.

I get no response back just a 406 error.

If i do the same request in android I get a filenotfound error. Weird part is all the other api calls are working perfectly fine.

let me know if youd like me to post any other information. If needed I can post the android java httprequest and how i have it formatted and setup.
Did you try this with an app such as postman or insomnia ? I get no error with that file...

no need to track too far in your code implementation, it is important we work in a similar environment so I can replicate the errors you may find.

Figured it out!!! So apparently I have to also provide a user agent in my POST. Anyways, thank you for the time you spent trying to help me! On a side note, is there any way I could partner up with opensubtitles and give an increased download quota to users that use the app after it is released??

Re: Open subtitles API download issue

Posted: Mon Sep 13, 2021 6:49 am
by oss
Please let us know, if it is not clear from Documentation, that is needed to address some issues with it, so this won't happen for other users. With downloading subtitles - higher quota - please contact us directly.

Thanks

Re: Open subtitles API download issue

Posted: Wed Sep 15, 2021 10:35 pm
by kva1992
Please let us know, if it is not clear from Documentation, that is needed to address some issues with it, so this won't happen for other users. With downloading subtitles - higher quota - please contact us directly.

Thanks
So I am able to generate the download link but is it possible to get a downloadable srt file link? Right now if I am not mistaken it returns a link that is viewable in the browser rather than prompting to download the srt file itself. I am using LibVLC and tried to initiate a download but it failed because it was coming in as a stream i guess? But when i manually generated a download link from opensubtitles.com by going to a movie and clicking download and waiting for the download the file url worked perfectly fine in libvlc.

Re: Open subtitles API download issue

Posted: Thu Sep 16, 2021 8:51 am
by os_dev
Please let us know, if it is not clear from Documentation, that is needed to address some issues with it, so this won't happen for other users. With downloading subtitles - higher quota - please contact us directly.

Thanks
So I am able to generate the download link but is it possible to get a downloadable srt file link? Right now if I am not mistaken it returns a link that is viewable in the browser rather than prompting to download the srt file itself. I am using LibVLC and tried to initiate a download but it failed because it was coming in as a stream i guess? But when i manually generated a download link from opensubtitles.com by going to a movie and clicking download and waiting for the download the file url worked perfectly fine in libvlc.

Well it's the same code that generates the link on the website and on the api. It's not a stream, but indeed a file you can simply query to download.

but the link is only valid for about 3 hours, so it can never be cached, maybe you were trying to download a cached result ?

Re: Open subtitles API download issue

Posted: Thu Sep 16, 2021 5:44 pm
by kva1992
Please let us know, if it is not clear from Documentation, that is needed to address some issues with it, so this won't happen for other users. With downloading subtitles - higher quota - please contact us directly.

Thanks
So I am able to generate the download link but is it possible to get a downloadable srt file link? Right now if I am not mistaken it returns a link that is viewable in the browser rather than prompting to download the srt file itself. I am using LibVLC and tried to initiate a download but it failed because it was coming in as a stream i guess? But when i manually generated a download link from opensubtitles.com by going to a movie and clicking download and waiting for the download the file url worked perfectly fine in libvlc.

Well it's the same code that generates the link on the website and on the api. It's not a stream, but indeed a file you can simply query to download.

but the link is only valid for about 3 hours, so it can never be cached, maybe you were trying to download a cached result ?
Hello,

Thank you for responding so fast. Much appreciated. That said, I can actually confirm it was not cached because I ran the download method right before getting the link. On top of that, the link it generated I put into my regular browser and was able to see the content of the link in the browser which is the issue from what I can tell. Whereas the other download link I received from the website was just a file and it prompted a download the second I put it into my browser. Is there anything I could provide to help you diagnose the issue I am having?

I have attached a screenshot of how the link is generated when I visit the link on a browser below.
Capture.PNG
Capture.PNG (40.72 KiB) Viewed 15557 times

Re: Open subtitles API download issue

Posted: Fri Sep 17, 2021 9:02 am
by os_dev
Oh I got it

So, if you get the download prompt, it means the file is downloaded for the first time, coming from our server I control the headers, and can make it start downloading.

if the file has already been queried once, it'll be fetched by the cloudflare cache and just come up in your browser.

Re: Open subtitles API download issue

Posted: Fri Sep 17, 2021 9:24 am
by kva1992
Oh I got it

So, if you get the download prompt, it means the file is downloaded for the first time, coming from our server I control the headers, and can make it start downloading.

if the file has already been queried once, it'll be fetched by the cloudflare cache and just come up in your browser.
Ahh, So apparently the Cloudflare is the issue. It is blocking me from downloading it. Just confirmed this with a dev on the VLC repository. He said nothing they can do, its on your end. Anything you can do to address the issue?

Re: Open subtitles API download issue

Posted: Fri Sep 17, 2021 11:08 am
by os_dev
Oh I got it

So, if you get the download prompt, it means the file is downloaded for the first time, coming from our server I control the headers, and can make it start downloading.

if the file has already been queried once, it'll be fetched by the cloudflare cache and just come up in your browser.
Ahh, So apparently the Cloudflare is the issue. It is blocking me from downloading it. Just confirmed this with a dev on the VLC repository. He said nothing they can do, its on your end. Anything you can do to address the issue?
Allright, so, I prepared something you can try.

https://opensubtitles.stoplight.io/docs ... nload/post

add the parameter "force_download=1" when you request the download link, let me know if it solves your problem

Re: Open subtitles API download issue

Posted: Fri Sep 17, 2021 9:04 pm
by kva1992
Oh I got it

So, if you get the download prompt, it means the file is downloaded for the first time, coming from our server I control the headers, and can make it start downloading.

if the file has already been queried once, it'll be fetched by the cloudflare cache and just come up in your browser.
Ahh, So apparently the Cloudflare is the issue. It is blocking me from downloading it. Just confirmed this with a dev on the VLC repository. He said nothing they can do, its on your end. Anything you can do to address the issue?
Allright, so, I prepared something you can try.

https://opensubtitles.stoplight.io/docs ... nload/post

add the parameter "force_download=1" when you request the download link, let me know if it solves your problem
Just tried that and I get the same error. It looks like Cloudflare is blocking it and giving me a 500 error. Below is the error log snapshot.

Code: Select all

2021-09-17 11:56:35.957 2759-2967/com.test.test D/VLC: [a76414d0/b97] http stream: in HEADERS (0x01) frame of 637 bytes, flags 0x04, stream 1 2021-09-17 11:56:35.957 2759-2967/com.test.test D/VLC: [a76414d0/b97] http stream: stream 1 16 headers: 2021-09-17 11:56:35.957 2759-2967/com.test.test D/VLC: [a76414d0/b97] http stream: :status: "500" 2021-09-17 11:56:35.957 2759-2967/com.test.test D/VLC: [a76414d0/b97] http stream: date: "Fri, 17 Sep 2021 18:56:36 GMT" 2021-09-17 11:56:35.957 2759-2967/com.test.test D/VLC: [a76414d0/b97] http stream: content-type: "text/html; charset=UTF-8" 2021-09-17 11:56:35.957 2759-2967/com.test.test D/VLC: [a76414d0/b97] http stream: x-request-id: "9e3b3651-7d4b-4d14-95a8-dd24119c1054" 2021-09-17 11:56:35.957 2759-2967/com.test.test D/VLC: [a76414d0/b97] http stream: x-runtime: "0.024585" 2021-09-17 11:56:35.957 2759-2967/com.test.test D/VLC: [a76414d0/b97] http stream: vary: "Origin" 2021-09-17 11:56:35.957 2759-2967/com.test.test D/VLC: [a76414d0/b97] http stream: x-cache-backend: "rb2" 2021-09-17 11:56:35.957 2759-2967/com.test.test D/VLC: [a76414d0/b97] http stream: x-var-cache: "MISS" 2021-09-17 11:56:35.957 2759-2967/com.test.test D/VLC: [a76414d0/b97] http stream: x-via: "fw1" 2021-09-17 11:56:35.957 2759-2967/com.test.test D/VLC: [a76414d0/b97] http stream: cf-cache-status: "BYPASS" 2021-09-17 11:56:35.957 2759-2967/com.test.test D/VLC: [a76414d0/b97] http stream: expect-ct: "max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"" 2021-09-17 11:56:35.957 2759-2967/com.test.test D/VLC: [a76414d0/b97] http stream: report-to: "{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=EFLdWAHGVL37wxD3v9ccMmuCH0Sd2G8mNLF4asnaRkAyNTzoWkBzzPLleO%2BZLm6VfiMc2Xunyeb2r9WSpDv4ZVx1Kw0zhbKQPGY17wo%2FokWO6xyVZY7%2Bu8B3Yj%2FiPqZC5AGyoMmzfA%3D%3D"}],"group":"cf-nel","max_age":604800}" 2021-09-17 11:56:35.957 2759-2967/com.test.test D/VLC: [a76414d0/b97] http stream: nel: "{"success_fraction":0,"report_to":"cf-nel","max_age":604800}" 2021-09-17 11:56:35.957 2759-2967/com.test.test D/VLC: [a76414d0/b97] http stream: server: "cloudflare" 2021-09-17 11:56:35.957 2759-2967/com.test.test D/VLC: [a76414d0/b97] http stream: cf-ray: "69048e315a063655-LAX" 2021-09-17 11:56:35.957 2759-2967/com.test.test D/VLC: [a76414d0/b97] http stream: alt-svc: "h3=":443"; ma=86400, h3-29=":443"; ma=86400, h3-28=":443"; ma=86400, h3-27=":443"; ma=86400" 2021-09-17 11:56:35.957 2759-2967/com.test.test D/VLC: [a76414d0/b97] http stream: in DATA (0x00) frame of 3060 bytes, flags 0x00, stream 1 2021-09-17 11:56:35.957 2759-2967/com.test.test D/VLC: [a76414d0/b97] http stream: out (priority) WINDOW_UPDATE (0x08) frame of 4 bytes, flags 0x00, global 2021-09-17 11:56:35.957 2759-2967/com.test.test D/VLC: [a76414d0/b97] http stream: in DATA (0x00) frame of 0 bytes, flags 0x01, stream 1 2021-09-17 11:56:35.957 2759-2967/com.test.test D/VLC: [a76414d0/b97] http stream: stream 1 closed by peer 2021-09-17 11:56:35.957 2759-2823/com.test.test E/VLC: [a76414d0/b07] libvlc stream: HTTP 500 error 2021-09-17 11:56:35.957 2759-2823/com.test.test E/VLC: [a76414d0/b07] http stream: local stream 1 error: Cancellation (0x8) 2021-09-17 11:56:35.957 2759-2823/com.test.test D/VLC: [a76414d0/b07] http stream: out RST_STREAM (0x03) frame of 4 bytes, flags 0x00, stream 1 2021-09-17 11:56:35.957 2759-2823/com.test.test D/VLC: [a76414d0/b07] http stream: local shutdown 2021-09-17 11:56:35.957 2759-2823/com.test.test D/VLC: [a76414d0/b07] http stream: out GOAWAY (0x07) frame of 8 bytes, flags 0x00, global 2021-09-17 11:56:35.982 2759-2851/com.test.test D/EGL_emulation: eglMakeCurrent: 0xa7606bc0: ver 2 0 (tinfo 0x95861c30) 2021-09-17 11:56:36.007 2759-2851/com.test.test D/EGL_emulation: eglMakeCurrent: 0xa7606bc0: ver 2 0 (tinfo 0x95861c30) 2021-09-17 11:56:36.078 2759-2851/com.test.test D/EGL_emulation: eglMakeCurrent: 0xa7606bc0: ver 2 0 (tinfo 0x95861c30) 2021-09-17 11:56:36.135 2759-2851/com.test.test D/EGL_emulation: eglMakeCurrent: 0xa7606bc0: ver 2 0 (tinfo 0x95861c30) 2021-09-17 11:56:36.197 2759-2851/com.test.test D/EGL_emulation: eglMakeCurrent: 0xa7606bc0: ver 2 0 (tinfo 0x95861c30) 2021-09-17 11:56:36.209 2759-2823/com.test.test D/VLC: [a76414d0/b07] libvlc stream: no access modules matched 2021-09-17 11:56:36.209 2759-2823/com.test.test W/VLC: [a39f2e30/b07] libvlc input: failed to add https://www.opensubtitles.com/download/24163ECB2EA33048BE646F43DFEBE4E93D5B384A6436DCB4F0938572E1A9C471750FA6DACD2DA5975434665796161CE0BDBEB70174F96C69A23CB00E08762CFCB8C9E8848551E92859D264CF622C34B6CA32EC5EDD9C030ABFBE11985A3C0C4C719AEBE9B7ABCAEC2B89681583A161F28B931AC48DBAEFA74F5BB9B351DEE2C25BEFAE1FF70463DD45E26512850DCB68D862A2209559B02CA869A1A9914DE24C/subfile/test123.srt as slave

Re: Open subtitles API download issue

Posted: Sat Sep 18, 2021 3:12 am
by oss
it is quite strange, because it works here, important thing is to always create fresh download. If possible try to send all REQUESTS and RESPONSE, so we can debug further.

I also recommend we change error 500, when link is expired to something more descriptive like
https://developer.mozilla.org/en-US/doc ... Status/410

Re: Open subtitles API download issue

Posted: Sat Sep 18, 2021 7:01 am
by kva1992
it is quite strange, because it works here, important thing is to always create fresh download. If possible try to send all REQUESTS and RESPONSE, so we can debug further.

I also recommend we change error 500, when link is expired to something more descriptive like
https://developer.mozilla.org/en-US/doc ... Status/410
Sure, I will try to post a log of all the requests and responses. But pretty much the above is the response I received when passing the subtitle file link which was generated using the API to VLC ( I am using libVLC). Because I need to finish up the project I am going to be pausing development on the open subtitles feature of the app and continue with it again at a later date especially considering there is not much I can do on my end. If I do come across a solution I will make sure to update on the forum and I hope to get updates if any updates or tweaks are made. I will periodically check the forums for updates.

Edited:
On a side note, just tried downloaded the file manually put it on my server, and provided a URI to the file like before and it worked properly and added the subtitles without any issues. So the file is not the issue it is the way it is being delivered.