all repos — tmdb-desktop-client @ b820fcafd3dc14e660da50e6017c651dab89e38c

A simple tmdb desktop client written in Java

src/com/oocpro/tmdbdesktop/tmdb/Search.java

package com.oocpro.tmdbdesktop.tmdb;

import com.oocpro.tmdbdesktop.Constants;
import java.net.URL;
import java.net.MalformedURLException;
import java.io.*;
import org.json.*;
import javax.swing.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

     public class Search{
        public static List<Integer> IDs;
            public Search(String MOVIE_NAME)throws IOException,MalformedURLException{                                          //CONSTRUCTOR TO INITIALISE MOVIE ID
                String s_url=Constants.BASEURL+"/search/movie?api_key="+Constants.API_KEY+"&language=en-US&query=%s";     //General URL format for finding a movie
                String url=String.format(s_url,MOVIE_NAME);                              //Adding the query
                System.out.println("URL = "+url);
                URL us1 = new URL(url);                                             //Creating url object 
                InputStream sres = (InputStream)us1.getContent();                   //Storing the stream of data we get from the url
                JSONObject ja = new JSONObject(new JSONTokener(sres));
                IDs = new ArrayList<Integer>();
                Iterator IDS_itr = ja.getJSONArray("results").iterator();
                //Iterating through all the results generated by the query and
                //getting the IDs of each result
                while(IDS_itr.hasNext()){
                    JSONObject id = (JSONObject)IDS_itr.next();
                    IDs.add(id.getInt("id"));
                }

                //System.out.println(IDs.get(1) + " ");
                //System.out.println(ja.toString(1));

            
              //System.out.println(ja.getNames(ja));
              //System.out.println(" "+ja.getInt("total_pages"));
        
        
        }
        //public static void main(String args[])throws IOException{
         //   Search sc = new Search();
        //}
    }