wtekiela / opensub4j Goto Github PK
View Code? Open in Web Editor NEWJava library for communicating with opensubtitles.org XML-RPC API
License: Other
Java library for communicating with opensubtitles.org XML-RPC API
License: Other
Hello,
I am trying this library for a class project. But I keep getting java.lang.NullPointerException
. Don't know what's causing this. Can take a look?
subtitles = osClient.searchSubtitles("eng", "Friends", "1", "1");
is causing the exception.
Here is my code.
List<SubtitleInfo> subtitles;
try {
URL serverUrl = new URL("https", "api.opensubtitles.org", 443, "/xml-rpc");
OpenSubtitlesClient osClient = new OpenSubtitlesClientImpl(serverUrl);
osClient.login("myID", "andPassword", "en", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0");
System.out.println(osClient.isLoggedIn());
subtitles = osClient.searchSubtitles("eng", "Friends", "1", "1");
osClient.logout();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (XmlRpcException e) {
e.printStackTrace();
}
Thanks a lot 😄
java.lang.ClassCastException: java.lang.Boolean cannot be cast to [Ljava.lang.Object;
at com.github.wtekiela.opensub4j.impl.ResponseParser.bindList(ResponseParser.java:28)
at com.github.wtekiela.opensub4j.impl.ListOperation.execute(ListOperation.java:28)
at com.github.wtekiela.opensub4j.impl.OpenSubtitlesClientImpl.downloadSubtitles(OpenSubtitlesClientImpl.java:147)
at Test.main(Test.java:20)
Using the opensub4j v0.2.3 from mvnrepository gets me this error when trying to login:
Exception in thread "Thread-0" java.lang.IllegalArgumentException: Can not set com.github.wtekiela.opensub4j.response.ResponseStatus field com.github.wtekiela.opensub4j.response.Response.status to java.lang.String
at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
at java.base/jdk.internal.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81)
at java.base/java.lang.reflect.Field.set(Field.java:780)
at com.github.wtekiela.opensub4j.impl.ResponseParser.set(ResponseParser.java:147)
at com.github.wtekiela.opensub4j.impl.ResponseParser.executeFieldBinding(ResponseParser.java:83)
at com.github.wtekiela.opensub4j.impl.ResponseParser.bindField(ResponseParser.java:66)
at com.github.wtekiela.opensub4j.impl.ResponseParser.bind(ResponseParser.java:45)
at com.github.wtekiela.opensub4j.impl.AbstractOperation.execute(AbstractOperation.java:25)
at com.github.wtekiela.opensub4j.impl.OpenSubtitlesClientImpl.login(OpenSubtitlesClientImpl.java:109)
This is my code:
URL serverUrl = new URL("https", "api.opensubtitles.org", 443, "/xml-rpc");
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(serverUrl);
config.setConnectionTimeout(100);
config.setReplyTimeout(100);
config.setGzipCompressing(true);
osClient = new OpenSubtitlesClientImpl(config);
Response response = osClient.login(Program.USERNAME, Program.PASSWORD, "en", "TemporaryUserAgent");
Hi friend. THanks for the great work. Is it possible to update your project in mvn repository?
Thanks!!
Should the username and password be registered in https://www.opensubtitles.org/zh/newuser
Currently when we login with a user we only get the token back as login response.
However from OpenSubtitles we get a response something like below when we login,
{seconds=0.048, data={UserRank=##, UserNickName=##, UploadCnt=xxx, DownloadCnt=xxx, IsVIP=0, UserWebLanguage=en, IDUser=xxxxx, UserPreferedLanguages=eng}, token=-abcdefgh1234, status=200 OK}
I am interested in the data as well in the login response.
Can you submit this project to maven central please? I would love to not use a .jar.
Is there any way to find out Subtitle encoding? When i get content from subtitle file it is encoded in UTF-8 by default. But some files are in other charsets, and they show incorect. I find that there is method getContent(String charsetName) . But i dont know charset of downloaded file to encode it correctly.
In response of search subtitles there is field sub encoding (https://trac.opensubtitles.org/projects/opensubtitles/wiki/XMLRPC#DownloadSubtitles).
I cant find in your library it implementation. And i dont know how to add it.
When we try to download subtitles for an user whose daily limit is reached we get the below response,
{seconds=0.004, data=false, status=407 Download limit reached}
The data is false here where are we are expecting a list because of which we get the below exception.
Response: {seconds=0.004, data=false, status=407 Download limit reached}
java.lang.ClassCastException: java.lang.Boolean cannot be cast to [Ljava.lang.Object;
at com.github.wtekiela.opensub4j.impl.ResponseParser$FieldBindingTask.executeListFieldBinding(ResponseParser.java:122)
at com.github.wtekiela.opensub4j.impl.ResponseParser$FieldBindingTask.run(ResponseParser.java:107)
at com.github.wtekiela.opensub4j.impl.ResponseParser.bind(ResponseParser.java:51)
at com.github.wtekiela.opensub4j.impl.AbstractListOperation.execute(AbstractListOperation.java:25)
at com.github.wtekiela.opensub4j.impl.OpenSubtitlesClientImpl.downloadSubtitles(OpenSubtitlesClientImpl.java:180)
Hello,
I have a SubtitleInfo object, but when I try to download it with
List<SubtitleFile> subtitleFiles = osClient.downloadSubtitles(best.getId());
I always get the following exception.
out 01, 2019 3:07:32 PM controller.DownloadSubtitlesController searchSubtitle
SEVERE: null
java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.Object;
at com.github.wtekiela.opensub4j.impl.ResponseParser.bindList(ResponseParser.java:26)
at com.github.wtekiela.opensub4j.impl.ListOperation.execute(ListOperation.java:28)
at com.github.wtekiela.opensub4j.impl.OpenSubtitlesClientImpl.downloadSubtitles(OpenSubtitlesClientImpl.java:183)
at controller.DownloadSubtitlesController.searchSubtitle(DownloadSubtitlesController.java:50)
at prometheus.Main.main(Main.java:37)
Any thoughts?
Why are downloads still 200 when logged in using OpenSub4j's VIP account?
Once we get the subtitle search data, I would also need to get the series Imdb id for episode subtitles
Hello!
Like your website, enter a movie name string to search for subtitles in all languages, how do I need to pass in parameters?
I looked at all the variants of the searchSubtitles method, but did not find a corresponding class method.
My code:
ListResponse<SubtitleInfo> searchSubRess = osClient.searchSubtitles("all", "mulan", "1", "1");
Search Result:
SubtitleInfo[id=3988248, subtitleFileId=1952661014, downloadsNo=421, language='German', fileName='Terriers.S01E01.Pilot.HDTV.XviD-FQM.srt', format='srt', osLink='http://www.opensubtitles.org/en/subtitles/3988248/sid-FjyBFhiA99Fefh03xluQkBvc6Z5/terriers-pilot-de', downloadLink='https://dl.opensubtitles.org/en/download/src-api/vrf-19a00c4c/sid-FjyBFhiA99Fefh03xluQkBvc6Z5/filead/1952661014.gz', zipDownloadLink='https://dl.opensubtitles.org/en/download/src-api/vrf-f5720bc3/sid-FjyBFhiA99Fefh03xluQkBvc6Z5/subad/3988248', encoding='CP1252']
This result is different from the website search result.
Is my operation wrong?
Hope you can help me? Thank you!
There seems no params set charset in XMLRPC download, but according to the sample, the download link can set charset:
https://dl.opensubtitles.org/en/download/src-api/vrf-19be0c59/sid-Es8Yw0zrLBHcaLjKikJ-2rHWo99/filead/1953189057.gz
https://dl.opensubtitles.org/en/download/subencoding-utf8/src-api/vrf-19be0c59/sid-Es8Yw0zrLBHcaLjKikJ-2rHWo99/filead/1953189057.gz
I had try the two download link, and it works by http. But I don't know how to do with XMLRPC.
Hello, I applied for vip account and userAgent, but when searching for subtitles, because there are more users requesting, I have reported an error (Too Many Requests), may I ask, is there any good way to lift this restriction?
When I use the search subtitles method with query and season and episode number I get the proper result however if I pass the series Imdb id instead of query with season and episode numbers I get all subtitle info for the complete series and that particular episode.
I have done the required changes for this in my local branch with some few more fields added in the SubtitleInfo pojo which I would like to have.
I would really appreciate if you can accept these changes.
2020-09-28 14:02:44.742 8416-8447/com.subprj W/System.err: java.lang.IllegalArgumentException: field com.github.wtekiela.opensub4j.response.Response.status has type com.github.wtekiela.opensub4j.response.ResponseStatus, got java.lang.String
2020-09-28 14:02:44.742 8416-8447/com.subprj W/System.err: at java.lang.reflect.Field.set(Native Method)
2020-09-28 14:02:44.743 8416-8447/com.subprj W/System.err: at com.github.wtekiela.opensub4j.impl.ResponseParser$FieldBindingTask.set(ResponseParser.java:208)
2020-09-28 14:02:44.743 8416-8447/com.subprj W/System.err: at com.github.wtekiela.opensub4j.impl.ResponseParser$FieldBindingTask.executePrimitiveFieldBinding(ResponseParser.java:140)
2020-09-28 14:02:44.743 8416-8447/com.subprj W/System.err: at com.github.wtekiela.opensub4j.impl.ResponseParser$FieldBindingTask.run(ResponseParser.java:109)
2020-09-28 14:02:44.743 8416-8447/com.subprj W/System.err: at com.github.wtekiela.opensub4j.impl.ResponseParser.bind(ResponseParser.java:62)
2020-09-28 14:02:44.743 8416-8447/com.subprj W/System.err: at com.github.wtekiela.opensub4j.impl.AbstractOperation.execute(AbstractOperation.java:24)
2020-09-28 14:02:44.743 8416-8447/com.subprj W/System.err: at com.github.wtekiela.opensub4j.impl.OpenSubtitlesClientImpl.login(OpenSubtitlesClientImpl.java:112)
2020-09-28 14:02:44.743 8416-8447/com.subprj W/System.err: at com.subprj.MainActivity$InitOpenSubTask.run(MainActivity.java:98)
2020-09-28 14:02:44.743 8416-8447/com.subprj W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
2020-09-28 14:02:44.743 8416-8447/com.subprj W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
2020-09-28 14:02:44.744 8416-8447/com.subprj W/System.err: at java.lang.Thread.run(Thread.java:764)
Adding dependency as directed in ReadMe and getting a failed to resolve error.
Error:(42, 13) Failed to resolve: com.github.wtekiela:opensub4j:0.2.0-SNAPSHOT
opensubtitles xml-api seemed to stopped accepting anonymous login, which results in integTests failing
I added the dependancy:
compile 'com.github.wtekiela:opensub4j:0.1.2'
I then followed the readme and added to my class:
public class Subtitles {
public Subtitles(){
URL serverUrl = new URL("https", "api.opensubtitles.org", 443, "/xml-rpc");
OpenSubtitlesClient osClient = new OpenSubtitlesClientImpl(serverUrl);
}
}
But i get the error:
Cant resolve symbol OpenSubtitlesClient.
and there is no way to import it
Seen in release 0.4.1
When I execute a query like this:
osClient.searchMoviesOnImdb("one flew over the cuckoo's nest");
The parsing of the MovieInfo
-response fails:
java.lang.NumberFormatException: For input string: "1989193839205"
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68)
at java.base/java.lang.Integer.parseInt(Integer.java:658)
at java.base/java.lang.Integer.parseInt(Integer.java:776)
at com.github.wtekiela.opensub4j.impl.ResponseParser$FieldBindingTask.parse(ResponseParser.java:217)
at com.github.wtekiela.opensub4j.impl.ResponseParser$FieldBindingTask.executePrimitiveFieldBinding(ResponseParser.java:143)
at com.github.wtekiela.opensub4j.impl.ResponseParser$FieldBindingTask.run(ResponseParser.java:131)
at com.github.wtekiela.opensub4j.impl.ResponseParser.bind(ResponseParser.java:85)
at com.github.wtekiela.opensub4j.impl.ResponseParser$FieldBindingTask.executeListFieldBinding(ResponseParser.java:158)
at com.github.wtekiela.opensub4j.impl.ResponseParser$FieldBindingTask.run(ResponseParser.java:133)
at com.github.wtekiela.opensub4j.impl.ResponseParser.bind(ResponseParser.java:74)
at com.github.wtekiela.opensub4j.impl.AbstractListOperation.execute(AbstractListOperation.java:25)
at com.github.wtekiela.opensub4j.impl.OpenSubtitlesClientImpl.searchMoviesOnImdb(OpenSubtitlesClientImpl.java:187)
I assume that MovieInfo#id
field should be long
instead of int
? Couldn't find any xmlrpc-api documents in opensubtitles to confirm this.
Hi sir, first of all thanks for your time and your work. Your library really saved me a lot of time for my subtitle managing application.
Although i'd like to note that downloadSubtitles() seems to not work, at least for me.
I use the 0.1.2 version, can you confirm the issue?
Thanks
URL serverUrl = new URL("https", "api.opensubtitles.org", 443, "/xml-rpc");
OpenSubtitlesClient osClient = new OpenSubtitlesClientImpl(serverUrl);
ServerInfo serverInfo = osClient.serverInfo(); >> here i'm getting "org.apache.xmlrpc.XmlRpcException: Exception occurred during XML-RPC call"
can you help me to solve this issue ?
Hi,
I am trying to switch to opensub4j in my Nova Video Player android application and when adding in dependencies implementation 'com.github.wtekiela:opensub4j:0.2.3'
I cannot build anymore my application and R8 throws the following error:
.gradle/caches/modules-2/files-2.1/junit/junit/3.8.1/99129f16442844f6a4a11ae22fbbee40b14d774f/junit-3.8.1.jar: R8: Illegal invoke-super to void java.awt.Component.setBounds(int, int, int, int) from class junit.awtui.ProgressBar
Would you have any workaround or recommendation?
Thank you for your work and contribution.
Hi. Is there any way to configure timeout on the requests?
It's very common to opensub has any instability and I noticed that there is no time out exception for these requests.
Thanks in advance.
Non utf-8 subtitles are displayed incorrectly, because the decompress method does not have into account the enconding when converting to string content.
ã -> ? and etc..
how to get subtitleInfo.getId() as mention in Download subtitle section.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.