public String trailerByTitle(String query) { // return apiC.getTrailer(qc.cleanTrailerString(query)); String[] array = qc.cleanTrailerString(query); String str = null; // "http://simpleapi.traileraddict.com/" + query + "/trailer" for (int i = 0; i < array.length; i++) { System.out.println("TESTING:" + array[i]); // Trailer trailer=apiC.getTrailer(array[i]); Trailer trailer = apiC.getTrailer("http://simpleapi.traileraddict.com/" + array[i] + "/trailer"); if (trailer.getTrailerID() != null) { str = gson.toJson(trailer); System.out.println("RETURN:" + str); return str; } } for (int i = 0; i < array.length; i++) { System.out.println("TESTING:" + array[i]); // Trailer trailer=apiC.getTrailer(array[i]); Trailer trailer = apiC.getTrailer("http://simpleapi.traileraddict.com/" + array[i] + "/trailer-a"); if (trailer.getTrailerID() != null) { str = gson.toJson(trailer); System.out.println("RETURN:" + str); return str; } } for (int i = 0; i < array.length; i++) { System.out.println("TESTING:" + array[i]); // Trailer trailer=apiC.getTrailer(array[i]); Trailer trailer = apiC.getTrailer("http://simpleapi.traileraddict.com/" + array[i] + "/trailer-b"); if (trailer.getTrailerID() != null) { str = gson.toJson(trailer); System.out.println("RETURN:" + str); return str; } } return null; }
/** * The Query parameter is used to find a specific movie trailer. Will return a Json doc as String * with a Link and Id to the Trailer. The Search Query will be cleaned and then the APIConnector * returns a JSON converted String. * * @param query -Search query for specific Trailer * @return String */ public String trailerByImdb(String query) { query = apiC.getTrailerTitle(qc.cleanImdbID(query)); if (query == null) { return null; } else { return gson.toJson( apiC.getTrailer( "http://simpleapi.traileraddict.com/" + qc.cleanTrailerTitle(query) + "/trailer")); } }