Skip to content

Commit

Permalink
[fix] tmdb 반환값 장르 1개인 경우도 저장할 수 있도록 수정, kofic 반환값 없을 경우 다시 api 요청할 수 …
Browse files Browse the repository at this point in the history
…있도록 수정
  • Loading branch information
syyling committed May 29, 2024
1 parent 65a9fd1 commit 7e4ab8f
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,16 @@ private TmdbResponse getTmdbResponse(String tmdbMovieId) {
Object title = jsonObject.get("title");
JSONArray genres = (JSONArray) jsonObject.get("genres");
StringBuilder genre = new StringBuilder();
for(int i=0; i<2; i++) {
JSONObject genreObject = (JSONObject) genres.get(i);
if(genres.length() == 1) {
JSONObject genreObject = (JSONObject) genres.get(0);
genre.append(genreObject.get("name"));
if(i==0) genre.append(",");
}
else{
for(int i=0; i<2; i++) {
JSONObject genreObject = (JSONObject) genres.get(i);
genre.append(genreObject.get("name"));
if(i==0) genre.append(",");
}
}
Object plot = jsonObject.get("overview");
Object poster = "https://image.tmdb.org/t/p/original" + jsonObject.get("poster_path");
Expand All @@ -65,6 +71,11 @@ private KoficResponse getKoficResponse(String title, String year) {
JSONObject apiResponse = new JSONObject(koficComponent.findMovieByTitleAndYear(koficKey, title, year, year));
JSONObject jsonObject = (JSONObject) apiResponse.get("movieListResult");
JSONArray dataResult = (JSONArray) jsonObject.get("movieList");
if(dataResult.isEmpty()) {
apiResponse = new JSONObject(koficComponent.findMovieByTitleAndYear(koficKey, title, "", ""));
jsonObject = (JSONObject) apiResponse.get("movieListResult");
dataResult = (JSONArray) jsonObject.get("movieList");
}
JSONObject movie = (JSONObject) dataResult.get(0);
String nation = movie.get("nationAlt").toString();
JSONArray directors = (JSONArray) movie.get("directors");
Expand Down

0 comments on commit 7e4ab8f

Please sign in to comment.