robertoestivill / ytsclient

Java library to consume YTS Rest API
Apache License 2.0
6 stars 2 forks source link

Api V2 #1

Closed rob1998 closed 9 years ago

rob1998 commented 9 years ago

Hi

I got this message: "NOTICE":"This API is deprecated and will not be in use in a few weeks, please update your applications to use APIv2, see our docs for more info". Are you going to update?

robertoestivill commented 9 years ago

Didn't know they updated the API. I will take a look at what changes are required and see if I can find the time to do it. Thanks for the heads up.

rob1998 commented 9 years ago

They also updated there website a few weeks ago, maybe they released a new api at the same moment? Thanks in advance!

robertoestivill commented 9 years ago

I will be working on this during this week. There will be a lot of changes since all the models have changed, and a few more methods have been aded. YtsClient will still be the only main class, but the api will change slightly.

rob1998 commented 9 years ago

Will I need to change my code?

robertoestivill commented 9 years ago

Yes, the Yts API v2 is not backward compatible. Because of this, I can not provide a backward compatible update of the library.

robertoestivill commented 9 years ago

I'm doing progress on the api_v2 branch.

I'm missing some integration tests and detail polishing, but is safe to say that the API will not change from now until the release of 0.2.0.

I would recommend to take a look at the branch README.md file, as it explains the new stuff.

rob1998 commented 9 years ago

Thank you for all your work! I'm having some problems with rx.Observable do I need to fix these or will it be removed from the final version?

robertoestivill commented 9 years ago

What kind of problems are you having? RxJava is a dependency on the project now, so the build should work just fine with both, Gradle and Maven.

rob1998 commented 9 years ago

I've never worked with Gradle or Maven so that's the problem, I use eclipse and I just import the libraries I need

robertoestivill commented 9 years ago

I will make the library available on Maven Central as part of the 0.2.0 release. I would recommend you to get familiarised as it's a standard to provide libraries dependencies easily.

rob1998 commented 9 years ago

Am I doing something wrong here:

private static YtsClient client = new YtsClient.Builder().withMovies().log( LogLevel.FULL ).url( "http://yts.re/api/v2" ).build();
Map<String, Object> options = new HashMap<>();
options.put("quality", "1080p");
options.put("limit", 48);
MovieModule moviesModule = client.movies();
System.out.println(moviesModule);
YtsResponse<MoviePage> response = moviesModule.list(options);
System.out.println(response);

Because it returns this:

retrofit.RestAdapter$RestHandler@2ee1104b
---> HTTP GET http://yts.re/api/v2/list_movies.json?limit=48&quality=1080p
---> END HTTP (no body)
<--- HTTP 302 http://yts.re/api/v2/list_movies.json?limit=48&quality=1080p (191ms)
X-Frame-Options: SAMEORIGIN
: HTTP/1.1 302 Found
X-Varnish: 68190085
Server: nginx
X-Content-Type-Options: nosniff
Connection: keep-alive
X-Frontend: SK
Content-Length: 0
Date: Tue, 24 Mar 2015 01:37:31 GMT
Location: https://yts.to/api/v2/list_movies.json?limit=48&quality=1080p

<--- END HTTP (0-byte body)
Exception in thread "AWT-EventQueue-0" retrofit.RetrofitError: 302 Found
    at retrofit.RetrofitError.httpError(RetrofitError.java:40)
    at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:388)
    at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240)
    at com.sun.proxy.$Proxy0.list(Unknown Source)
    at mediaCollector.GUI.loadMoviesDownloads(GUI.java:363)
    at mediaCollector.GUI$4.mouseClicked(GUI.java:197)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$500(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
robertoestivill commented 9 years ago

This is an API server domain redirect issue. I've tried it and I got an error the first time, but started working right after that test.

Apparently they changed the main DNS to yts.to, instead of yts.re. I would recommend you to initialize the YtsClient with url https://yts.to/api/v2 to avoid the overhead of the redirects.

rob1998 commented 9 years ago

Thank you!

robertoestivill commented 9 years ago

I have just merge the api_v2 into master, meaning that all API v2 is currently supported and have integration tests for samples.

robertoestivill commented 9 years ago

v0.2.0 has been released and gives full support for YTS api v2.

It's also available in Maven Central