Coder Social home page Coder Social logo

tmdb-java's Introduction

Pull requests (e.g. support for more API endpoints, bug fixes) are welcome!

tmdb-java

A Java wrapper around the TMDb v3 API using retrofit 2.

Usage

Available on Maven Central

Add the following dependency to your Gradle project:

implementation("com.uwetrottmann.tmdb2:tmdb-java:2.10.0")

or your Maven project:

<dependency>
    <groupId>com.uwetrottmann.tmdb2</groupId>
    <artifactId>tmdb-java</artifactId>
    <version>2.10.0</version>
</dependency>

Use like any other retrofit2 based service. For example:

// Create an instance of the service you wish to use
// you should re-use these
Tmdb tmdb = new Tmdb(API_KEY);
MoviesService moviesService = tmdb.moviesService();
// Call any of the available endpoints
try {
    Response<Movie> response = moviesService
        .summary(550)
        .execute();
    if (response.isSuccessful()) {
        Movie movie = response.body();
        System.out.println(movie.title + " is awesome!");
    }
} catch (Exception e) {
    // see execute() javadoc 
}

See test cases in src/test/ for more examples and the retrofit website for configuration options.

Android

This library ships Java 8 bytecode. This requires Android Gradle Plugin 3.2.x or newer.

Proguard / R8

It is likely not every method in this library is used, so it is probably useful to strip unused ones with Proguard. Apply the Proguard rules for retrofit.

The specific rules for this library are already bundled into the release which can be interpreted by R8 automatically, ProGuard users must manually add the rules.

License

This work by Uwe Trottmann is licensed under the Apache License 2.0.

Contributors and changes are tracked by Git.

Do not just copy, make it better.

tmdb-java's People

Contributors

cicoub13 avatar davidsben avatar dependabot[bot] avatar ethan-icet avatar gabrielsme avatar jackwakefield avatar jeremyquagmire avatar mlaggner avatar mostafamatar avatar myron0815 avatar nateshmbhat avatar proicons avatar serafo27 avatar sheigutn avatar simonvt avatar ssouris avatar utwyko avatar uwetrottmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tmdb-java's Issues

Error Tmdb Popular not adding values

Log error code

09-07 04:58:05.958 21040-21040/com.ITAN.cinematheque E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.ArrayIndexOutOfBoundsException: length=0; index=5
at com.ITAN.cinematheque.activities.MainActivity.onClick(MainActivity.java:84)
at android.view.View.performClick(View.java:4439)
at android.widget.Button.performClick(Button.java:139)
at android.view.View$PerformClick.run(View.java:18395)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5317)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)

doInBackground() Code

            int countt = 10;
            for(int i=1;i<countt;i++) {
                Tmdb tmdb = new Tmdb();
                tmdb.setApiKey("76f029219decc8a8e1c6d5474e37d7c9");
                MoviesService movieService = tmdb.moviesService();
                ResultsPage movie = movieService.popular(i,"en");
                int counttt = 19;
            for(int ii = 0; ii<counttt;ii++) {

                titlesa.add(movie.results.get(ii).title);
                DateFormat sdf = new SimpleDateFormat("dd-mm-yyyy");
                String str = sdf.format(movie.results.get(ii).release_date);
                rdatea.add(str);
                imageurla.add(movie.results.get(ii).poster_path);
                mida.add(movie.results.get(ii).id);

            }




               //you can use a String[] array at the place of 550.
               //String str = String.valueOf(movie.title);
           }
            //you can create multiple return statements or u can use if else statement for different   commands.
            return null;
            ///MenuInflater inflater = new MenuInflater(MainActivity.this);
            //inflater.inflate(android.R.layout.simple_list_item_1, false);


        }

error on method showToast(titles[5]);
The On Background method i not generating titles so titles index is = 0. so erro occurs.
The Problem is Why TMDB setting titles

movie.credits = null

Hi,
First thanks for this great and useful library ;)
I try to get the cast of the movie:

            api api = new api();
            Tmdb tmdb = new Tmdb();
            tmdb.setApiKey(api.getTHEMOVIEDBAPIKey());

            MoviesService movieService = tmdb.moviesService();
            Movie movie = movieService.summary(Integer.valueOf(name),      
           Locale.getDefault().getLanguage());

            for(int i = 0; i < movie.credits.cast.size(); i++)
            {
                cast.add(movie.credits.cast.get(i).name);
            }

I get a NullPointerException at for(int i = 0; i < movie.credits.cast.size(); i++)
Is there any special method to get the cast or the crew?

Thanks in advance
ternes3

Unable to view poster image

i did every thing but i was unable to set the imageview image from poster path

public class showMovieInfo extends AsyncTask<Integer,Integer,String>{

    protected void onPreExecute(Integer f){
        //setting up variables for whole method
    }

    @Override
    protected String doInBackground(Integer... params) {
        Tmdb tmdb = new Tmdb();
        tmdb.setApiKey("76f029219decc8a8e1c6d5474e37d7c9");
        MoviesService movieService = tmdb.moviesService();
        Movie movie = movieService.summary(550);
        //String str = String.valueOf(movie.title);

        return movie.overview;
       ///MenuInflater inflater = new MenuInflater(MainActivity.this);
        //inflater.inflate(android.R.layout.simple_list_item_1, false);


    }
    protected void onProgressUpdated(Integer... progress)
    {
    }
    protected void onPostExecute(String result)
    {
        Imageview.setImage(Picasso.with(this).load(painting.getImageUrl()).into(image);)
    }
}

Istancing new Tmdb launches excpetion

Thanks for your great work.
After build the maven project and so adding the built jar as library my project runs in excpetion due to:

Caused by: java.lang.ClassNotFoundException: retrofit.converter.Converter
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

Any help? All libraries has been correctly downloaded.
Thank you

Translations are missing

While there is an endpoint for translations, they are missing from the Movie Object. Since i'm java newbie i'm c# dev, i could make a pull request however tbh i don't have any clue how this is working and what is this @get attributes, anyway.

RxJava support

Any plans for adding support for RxJava by making service methods return observables?

Application Shuts Down Unexpectedly

Hi, Love This Library But Every Time It is Called the application stops unexpectedly..
i am using the following code

    TextView tv = (TextView) findViewById(R.id.textView);
    Tmdb tmdb = new Tmdb();
    tmdb.setApiKey("MYAPIKEY");
    //int idint = Integer.parseInt("tt2555736");
    MoviesService movieService = tmdb.moviesService();
    Movie movie = movieService.summary(550);
    String str = String.valueOf(movie.title);
    tv.setText(str);

when every this Activity Is Called The App Stops...
I Have Tried Every Thing... The Activity Works Fine If I Delete The Code...
I Am Using Min SDK VER 14
target SDK VER 19
Please Help.. i couldn't figure out what is the problem...

MovieService may be broken

After reading the retrofit 2 documentation and looking through the source, at least any @Get is possibly broken. The current TMDB API returns all info on movie/{movie_id}. However it appears that in the source that there are many calls to movie/{movie_id}/somecall (e.g movie/{movie_id}/release_dates. All returns appear to be null. I could make a PR that just returns the entire result on summary, but then the semantics of the API kinda break down. I can't find anything in the retrofit documentation on how to parse and return only specific parts of the response body. I just have learned about retrofit so I could be missing something.

Add trending endpoint

Hello !

First of all thank you for this wrapper you did an amazing job,
I saw that tmdb offers a "trending" endpoint (here)
I couldn't find the appropriate way to call that endpoint using this wrapper, is it already implemented ?

Thanks in advance !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.