Search in sources :

Example 1 with SpotifyPlaylistExporter

use of org.datatransferproject.transfer.spotify.playlists.SpotifyPlaylistExporter 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;
}
Also used : Monitor(org.datatransferproject.api.launcher.Monitor) AppCredentials(org.datatransferproject.types.transfer.auth.AppCredentials) SpotifyApi(com.wrapper.spotify.SpotifyApi) SpotifyPlaylistExporter(org.datatransferproject.transfer.spotify.playlists.SpotifyPlaylistExporter) SpotifyPlaylistImporter(org.datatransferproject.transfer.spotify.playlists.SpotifyPlaylistImporter) IOException(java.io.IOException)

Aggregations

SpotifyApi (com.wrapper.spotify.SpotifyApi)1 IOException (java.io.IOException)1 Monitor (org.datatransferproject.api.launcher.Monitor)1 SpotifyPlaylistExporter (org.datatransferproject.transfer.spotify.playlists.SpotifyPlaylistExporter)1 SpotifyPlaylistImporter (org.datatransferproject.transfer.spotify.playlists.SpotifyPlaylistImporter)1 AppCredentials (org.datatransferproject.types.transfer.auth.AppCredentials)1