Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] tmdb 반환값 장르 1개인 경우도 저장할 수 있도록 수정, kofic 반환값 없을 경우 다시 api 요청할 수 있도록 수정 #48

Merged
merged 1 commit into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading