aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprithugoswami <prithugoswami524@gmail.com>2019-05-01 00:18:39 +0530
committerprithugoswami <prithugoswami524@gmail.com>2019-05-01 00:18:39 +0530
commit111c2c3faa78ec2e9b3950e722090d52eddc85fd (patch)
tree82838dc5d5a20131e9f2ce145fd6ce0325fe0493
parentcb7a997bd93035c5c1983e3b423952ada714c283 (diff)
downloadtmdb-desktop-client-111c2c3faa78ec2e9b3950e722090d52eddc85fd.tar.gz
tmdb-desktop-client-111c2c3faa78ec2e9b3950e722090d52eddc85fd.zip
update `Movie.java` and `Main.java`
Main now has an example of usage of the `Movie` class.
-rw-r--r--src/com/oocpro/tmdbdesktop/Main.java6
-rw-r--r--src/com/oocpro/tmdbdesktop/Tmdb/Movie.java13
2 files changed, 7 insertions, 12 deletions
diff --git a/src/com/oocpro/tmdbdesktop/Main.java b/src/com/oocpro/tmdbdesktop/Main.java
index d612e0d..2fad6f4 100644
--- a/src/com/oocpro/tmdbdesktop/Main.java
+++ b/src/com/oocpro/tmdbdesktop/Main.java
@@ -6,8 +6,10 @@ import java.io.IOException;
public class Main{
public static void main (String [] args)throws IOException{
Movie ring = new Movie(565);
- System.out.println(ring.title);
- System.out.println(ring.genres);
+ 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);
}
}
diff --git a/src/com/oocpro/tmdbdesktop/Tmdb/Movie.java b/src/com/oocpro/tmdbdesktop/Tmdb/Movie.java
index f1eb198..9bbf32d 100644
--- a/src/com/oocpro/tmdbdesktop/Tmdb/Movie.java
+++ b/src/com/oocpro/tmdbdesktop/Tmdb/Movie.java
@@ -22,26 +22,19 @@ 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));
- JSONArray ja_genres = movie.getJSONArray("genres");
+ JSONArray ja_genres = movie.getJSONArray("genres");
Iterator genres_itr = ja_genres.iterator();
+
genres = new ArrayList<String>();
while(genres_itr.hasNext()){
JSONObject jo = (JSONObject)genres_itr.next();
genres.add(jo.getString("name"));
}
-
-
title = movie.getString("title");
year = movie.getString("release_date").substring(0,4);
plotline = movie.getString("overview");
+ rating = (float)movie.getDouble("vote_average");
}
-
- // String s_url=a_url+"search/movie?api_key="+api_key+"&query=%s";
- // String url=String.format(s_url,"CARS");
- // URL us1 = new URL(url);
- // InputStream sres = (InputStream)us1.getContent();
- // JSONArray ja = new JSONArray(new JSONTokener(sres));
- // System.out.println(ja.toString(4));
}