use of org.datatransferproject.transfer.spotify.playlists.SpotifyPlaylistImporter in project data-transfer-project by google.
the class SpotifyTransferExtension method initialize.
@Override
public void initialize(ExtensionContext context) {
if (initialized) {
Monitor monitor = context.getMonitor();
monitor.severe(() -> "SpotifyTransferExtension already initialized");
return;
}
AppCredentials appCredentials;
try {
appCredentials = context.getService(AppCredentialStore.class).getAppCredentials("SPOTIFY_KEY", "SPOTIFY_SECRET");
} catch (IOException e) {
Monitor monitor = context.getMonitor();
monitor.info(() -> "Unable to retrieve Spotify AppCredentials. " + "Did you set SPOTIFY_KEY and SPOTIFY_SECRET?");
return;
}
Monitor monitor = context.getMonitor();
SpotifyApi spotifyApi = new SpotifyApi.Builder().setClientId(appCredentials.getKey()).setClientSecret(appCredentials.getSecret()).build();
exporter = new SpotifyPlaylistExporter(monitor, spotifyApi);
importer = new SpotifyPlaylistImporter(monitor, spotifyApi);
initialized = true;
}
Aggregations