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.
haroldpoi
Posts: 19
Joined: Tue May 03, 2022 4:30 pm

problem with uploading programmatically

Sat May 03, 2025 5:53 pm

hello. I am trying to make a new OS library using golang, first as a cli tool, and later as a GUI app as well. In a way, I got the idea, because I would like to extend the functionality of the original OS uploader, but it is a little hard to build and run in developer mode (actually I couldn't make it yet). So I was thinking of rebuilding it as new from the ground up, with optimizations and speed in mind.

Now, for my question. The REST API wrapper part is pretty straight forward for most of the functionality (search, download).
I am having trouble replicating what OS uploader is doing with js and old os-api library using xml-rpc.I have successfully replicated the TryUpload function that checks if the subtitle already exists in the db, but then I can't see in what exact form he is sending the subtitle and the metadata to OS, so I am getting a reading body EOF error. So the problem is that I don't know how to format the data exactly before sending, and I can't find out what exactly the old api is expecting somewhere.

Here is a summary of my logs by an LLM:
]Target:
Subtitle File: pkg/core/opensubtitles/testdata/the woman who run 2020.srt
IMDB ID: 11697690
Language: ell
Pre-Check (TryUploadSubtitles)
Action: Attempting pre-upload check.
Key Params Sent: Subtitle Hash (a2e3...ee55), Filename, IMDB ID, Language.
Result: Success (HTTP 200 OK)
Outcome: Subtitle not already in database (alreadyindb: 0). Proceeding to upload.

Content Preparation
Action: Reading, Gzipping, and Base64 encoding subtitle file content.
Result: Encoded content generated (Length: 648).

Upload Attempt (UploadSubtitles)
Action: Attempting final upload with metadata and encoded content.
Key Params Sent: IMDB ID, Subtitle Hash, Filename, Base64 Content, Language, flags (HI=0, HD=0, etc.).
Result: Failed
Error Message: xmlrpc UploadSubtitles call failed: reading body EOF
The log: https://pastebin.com/jvHJ0g33

Can somebody help me? Here or in pm. Thanks!

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

Re: problem with uploading programmatically

Sat May 03, 2025 6:41 pm

Hi

please check https://trac.opensubtitles.org/opensubt ... tro#Upload
https://trac.opensubtitles.org/opensubt ... dSubtitles
https://trac.opensubtitles.org/opensubt ... dSubtitles

maybe you are gzipping them with header, it must be without header (subcontent)

now I am checking source and gzipping is optional, so just try to pass base64 contents there

'subcontent' => base64_encode($cd1)

let me know how it goes. I hope also Upload will be ready soon via REST...

haroldpoi
Posts: 19
Joined: Tue May 03, 2022 4:30 pm

Re: problem with uploading programmatically

Sun May 04, 2025 2:26 pm

Hi

please check https://trac.opensubtitles.org/opensubt ... tro#Upload
https://trac.opensubtitles.org/opensubt ... dSubtitles
https://trac.opensubtitles.org/opensubt ... dSubtitles

maybe you are gzipping them with header, it must be without header (subcontent)

now I am checking source and gzipping is optional, so just try to pass base64 contents there

'subcontent' => base64_encode($cd1)

let me know how it goes. I hope also Upload will be ready soon via REST...
thank you very much! docs and your advice helped me out a lot. I managed to upload a test sub, now I will try to test it more and make refactorings before publishing.
I am very excited about the new rest API upload endpoint. I will try to add it later and remove the old deprecated xml-rpc option.
Do you have information about an ETA for that? Let me know if I can help out somehow.

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

Re: problem with uploading programmatically

Sun May 04, 2025 7:52 pm

thats great, you can also share what you was doing wrong so other knows.

ETA for new API is unknown I would say, we all hoping ASAP

haroldpoi
Posts: 19
Joined: Tue May 03, 2022 4:30 pm

Re: problem with uploading programmatically

Tue May 13, 2025 6:33 pm

thats great, you can also share what you was doing wrong so other knows.

ETA for new API is unknown I would say, we all hoping ASAP
Sorry, I wrote a response text but due to internet problems at that moment, it never actually got posted.
So, I was doing both the gzip header thing wrong, and I also didn't know what the API was expecting, so I was sending the wrong uploadParams object/struct.

Return to “Developing”

Who is online

Users browsing this forum: No registered users and 2 guests