aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrashant Jha <prashant.kumarjha63@gmail.com>2019-05-01 18:18:26 +0530
committerPrashant Jha <prashant.kumarjha63@gmail.com>2019-05-01 18:18:26 +0530
commitb820fcafd3dc14e660da50e6017c651dab89e38c (patch)
tree80179380c7600aa0a814a01c3b7be9c9b29c5926
parentdbb011e0d83f3ec60650896845fae941b0885d48 (diff)
downloadtmdb-desktop-client-b820fcafd3dc14e660da50e6017c651dab89e38c.tar.gz
tmdb-desktop-client-b820fcafd3dc14e660da50e6017c651dab89e38c.zip
Works
-rw-r--r--src/com/oocpro/tmdbdesktop/Main.java18
-rw-r--r--src/com/oocpro/tmdbdesktop/tmdb/Movie.java2
-rw-r--r--src/com/oocpro/tmdbdesktop/tmdb/Search.java16
3 files changed, 20 insertions, 16 deletions
diff --git a/src/com/oocpro/tmdbdesktop/Main.java b/src/com/oocpro/tmdbdesktop/Main.java
index 58b008c..bbe2edc 100644
--- a/src/com/oocpro/tmdbdesktop/Main.java
+++ b/src/com/oocpro/tmdbdesktop/Main.java
@@ -1,15 +1,23 @@
package com.oocpro.tmdbdesktop;
import com.oocpro.tmdbdesktop.tmdb.Movie;
+import com.oocpro.tmdbdesktop.tmdb.Search;
import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.BufferedReader;
+
public class Main{
public static void main (String [] args)throws IOException{
- Movie ring = new Movie(565);
- System.out.println(ring.title + " ("+ring.year+")");
- System.out.println("Plotline: " + ring.plotline);
- System.out.println("Genres: " + ring.genres);
- System.out.println("Rating: " + ring.rating);
+ System.out.println("Enter a movie name to search ");
+ BufferedReader mname = new BufferedReader(new InputStreamReader(System.in));
+ String Mov_name = mname.readLine();
+ Search mv = new Search(Mov_name);
+ Movie det = new Movie(Search.IDs.get(1));
+ System.out.println(det.title + " ("+det.year+")");
+ System.out.println("Plotline: " + det.plotline);
+ System.out.println("Genres: " + det.genres);
+ System.out.println("Rating: " + det.rating);
}
}
diff --git a/src/com/oocpro/tmdbdesktop/tmdb/Movie.java b/src/com/oocpro/tmdbdesktop/tmdb/Movie.java
index e76fcbb..22923c0 100644
--- a/src/com/oocpro/tmdbdesktop/tmdb/Movie.java
+++ b/src/com/oocpro/tmdbdesktop/tmdb/Movie.java
@@ -23,7 +23,7 @@ public class Movie{
String geturl = MOVIEBASEURL+id+"?api_key="+Constants.API_KEY;
InputStream res = (InputStream)new URL(geturl).getContent();
JSONObject movie = new JSONObject(new JSONTokener(res));
- System.out.println(movie.toString(1));
+ //System.out.println(movie.toString(1));
genres = new ArrayList<String>();
Iterator genres_itr = movie.getJSONArray("genres").iterator();
diff --git a/src/com/oocpro/tmdbdesktop/tmdb/Search.java b/src/com/oocpro/tmdbdesktop/tmdb/Search.java
index 4caa3bd..71bd808 100644
--- a/src/com/oocpro/tmdbdesktop/tmdb/Search.java
+++ b/src/com/oocpro/tmdbdesktop/tmdb/Search.java
@@ -11,12 +11,8 @@ import java.util.Iterator;
import java.util.List;
public class Search{
- static String MOVIE_NAME;
- public List<Integer> IDs;
- public Search()throws IOException,MalformedURLException{ //CONSTRUCTOR TO INITIALISE MOVIE ID
- System.out.println("ENTER MOVIE NAME TO SEARCH ");
- BufferedReader mnm = new BufferedReader(new InputStreamReader(System.in));
- MOVIE_NAME = mnm.readLine();
+ 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);
@@ -32,7 +28,7 @@ import java.util.List;
IDs.add(id.getInt("id"));
}
- System.out.println(IDs + " ");
+ //System.out.println(IDs.get(1) + " ");
//System.out.println(ja.toString(1));
@@ -41,9 +37,9 @@ import java.util.List;
}
- public static void main(String args[])throws IOException{
- Search sc = new Search();
- }
+ //public static void main(String args[])throws IOException{
+ // Search sc = new Search();
+ //}
}