Skip to content

Commit

Permalink
fix: 플레이리스트 id조회하는 것을 플레이리스트 생성 후 1분 30초 대기후 조회하도록 수정(#132)
Browse files Browse the repository at this point in the history
- 굉장히 별로
  • Loading branch information
hong-sile committed Aug 30, 2024
1 parent d811e10 commit ca94f57
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/main/java/play/pluv/oauth/apple/AppleApiClient.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package play.pluv.oauth.apple;

import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VALUE;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -11,7 +12,6 @@
import org.springframework.web.service.annotation.PostExchange;
import play.pluv.oauth.apple.dto.AppleAddMusicRequest;
import play.pluv.oauth.apple.dto.AppleCreatePlayListRequest;
import play.pluv.oauth.apple.dto.AppleCreatePlayListResponse;
import play.pluv.oauth.apple.dto.AppleMusicSongs;
import play.pluv.oauth.apple.dto.ApplePlayListMusicResponses;
import play.pluv.oauth.apple.dto.ApplePlayListResponses;
Expand Down Expand Up @@ -48,8 +48,8 @@ AppleMusicSongs searchMusicByIsrc(
@RequestParam("filter[isrc]") final String isrc
);

@PostExchange(url = "https://api.music.apple.com/v1/me/library/playlists")
AppleCreatePlayListResponse createPlayList(
@PostExchange(url = "https://api.music.apple.com/v1/me/library/playlists", contentType = APPLICATION_JSON_VALUE)
String createPlayList(
@RequestHeader("Authorization") final String developerToken,
@RequestHeader("Music-User-Token") final String musicUserToken,
@RequestBody final AppleCreatePlayListRequest request
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/play/pluv/oauth/apple/AppleConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import play.pluv.music.domain.MusicId;
import play.pluv.oauth.apple.dto.AppleAddMusicRequest;
import play.pluv.oauth.apple.dto.AppleCreatePlayListRequest;
import play.pluv.oauth.apple.dto.ApplePlayListResponses;
import play.pluv.oauth.apple.dto.AppleTokenResponse;
import play.pluv.oauth.application.SocialLoginClient;
import play.pluv.oauth.domain.OAuthMemberInfo;
Expand Down Expand Up @@ -106,8 +107,15 @@ public List<PlayListMusic> getMusics(final String playListId, final String music
@Override
public PlayListId createPlayList(final String musicUserToken, final String name) {
final AppleCreatePlayListRequest request = AppleCreatePlayListRequest.from(name);
return appleApiClient.createPlayList(developerAuthorization, musicUserToken, request)
.getId();
appleApiClient.createPlayList(developerAuthorization, musicUserToken, request);
try {
Thread.sleep(1000 * 90);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
final ApplePlayListResponses playLists = appleApiClient.getPlayList(developerAuthorization,
musicUserToken);
return playLists.recentPlayListIds();
}

@Override
Expand Down

0 comments on commit ca94f57

Please sign in to comment.