Search in sources :

Example 6 with SpotifyWebApiException

use of se.michaelthelin.spotify.exceptions.SpotifyWebApiException in project spotify-web-api-java by spotify-web-api-java.

the class AuthorizationCodeRefreshExample method authorizationCodeRefresh_Sync.

public static void authorizationCodeRefresh_Sync() {
    try {
        final AuthorizationCodeCredentials authorizationCodeCredentials = authorizationCodeRefreshRequest.execute();
        // Set access and refresh token for further "spotifyApi" object usage
        spotifyApi.setAccessToken(authorizationCodeCredentials.getAccessToken());
        System.out.println("Expires in: " + authorizationCodeCredentials.getExpiresIn());
    } catch (IOException | SpotifyWebApiException | ParseException e) {
        System.out.println("Error: " + e.getMessage());
    }
}
Also used : IOException(java.io.IOException) ParseException(org.apache.hc.core5.http.ParseException) SpotifyWebApiException(se.michaelthelin.spotify.exceptions.SpotifyWebApiException) AuthorizationCodeCredentials(se.michaelthelin.spotify.model_objects.credentials.AuthorizationCodeCredentials)

Example 7 with SpotifyWebApiException

use of se.michaelthelin.spotify.exceptions.SpotifyWebApiException in project spotify-web-api-java by spotify-web-api-java.

the class GetArtistExample method getArtist_Sync.

public static void getArtist_Sync() {
    try {
        final Artist artist = getArtistRequest.execute();
        System.out.println("Name: " + artist.getName());
    } catch (IOException | SpotifyWebApiException | ParseException e) {
        System.out.println("Error: " + e.getMessage());
    }
}
Also used : Artist(se.michaelthelin.spotify.model_objects.specification.Artist) IOException(java.io.IOException) ParseException(org.apache.hc.core5.http.ParseException) SpotifyWebApiException(se.michaelthelin.spotify.exceptions.SpotifyWebApiException)

Example 8 with SpotifyWebApiException

use of se.michaelthelin.spotify.exceptions.SpotifyWebApiException in project spotify-web-api-java by spotify-web-api-java.

the class GetInformationAboutUsersCurrentPlaybackExample method getInformationAboutUsersCurrentPlayback_Sync.

public static void getInformationAboutUsersCurrentPlayback_Sync() {
    try {
        final CurrentlyPlayingContext currentlyPlayingContext = getInformationAboutUsersCurrentPlaybackRequest.execute();
        System.out.println("Timestamp: " + currentlyPlayingContext.getTimestamp());
    } catch (IOException | SpotifyWebApiException | ParseException e) {
        System.out.println("Error: " + e.getMessage());
    }
}
Also used : CurrentlyPlayingContext(se.michaelthelin.spotify.model_objects.miscellaneous.CurrentlyPlayingContext) IOException(java.io.IOException) ParseException(org.apache.hc.core5.http.ParseException) SpotifyWebApiException(se.michaelthelin.spotify.exceptions.SpotifyWebApiException)

Example 9 with SpotifyWebApiException

use of se.michaelthelin.spotify.exceptions.SpotifyWebApiException in project spotify-web-api-java by spotify-web-api-java.

the class AddItemsToPlaylistExample method addItemsToPlaylist_Sync.

public static void addItemsToPlaylist_Sync() {
    try {
        final SnapshotResult snapshotResult = addItemsToPlaylistRequest.execute();
        System.out.println("Snapshot ID: " + snapshotResult.getSnapshotId());
    } catch (IOException | SpotifyWebApiException | ParseException e) {
        System.out.println("Error: " + e.getMessage());
    }
}
Also used : SnapshotResult(se.michaelthelin.spotify.model_objects.special.SnapshotResult) IOException(java.io.IOException) ParseException(org.apache.hc.core5.http.ParseException) SpotifyWebApiException(se.michaelthelin.spotify.exceptions.SpotifyWebApiException)

Example 10 with SpotifyWebApiException

use of se.michaelthelin.spotify.exceptions.SpotifyWebApiException in project spotify-web-api-java by spotify-web-api-java.

the class CreatePlaylistExample method createPlaylist_Sync.

public static void createPlaylist_Sync() {
    try {
        final Playlist playlist = createPlaylistRequest.execute();
        System.out.println("Name: " + playlist.getName());
    } catch (IOException | SpotifyWebApiException | ParseException e) {
        System.out.println("Error: " + e.getMessage());
    }
}
Also used : Playlist(se.michaelthelin.spotify.model_objects.specification.Playlist) IOException(java.io.IOException) ParseException(org.apache.hc.core5.http.ParseException) SpotifyWebApiException(se.michaelthelin.spotify.exceptions.SpotifyWebApiException)

Aggregations

IOException (java.io.IOException)27 ParseException (org.apache.hc.core5.http.ParseException)27 SpotifyWebApiException (se.michaelthelin.spotify.exceptions.SpotifyWebApiException)27 AuthorizationCodeCredentials (se.michaelthelin.spotify.model_objects.credentials.AuthorizationCodeCredentials)5 SnapshotResult (se.michaelthelin.spotify.model_objects.special.SnapshotResult)3 Playlist (se.michaelthelin.spotify.model_objects.specification.Playlist)3 User (se.michaelthelin.spotify.model_objects.specification.User)2 SpotifyToYoutubeInterpreter (de.lundy.lobster.lavaplayer.spotify.SpotifyToYoutubeInterpreter)1 BotInstanceManagementService (de.notecho.spotify.bot.BotInstanceManagementService)1 BaseModule (de.notecho.spotify.bot.modules.BaseModule)1 TokenPair (de.notecho.spotify.database.user.entities.TokenPair)1 UserRepository (de.notecho.spotify.database.user.repository.UserRepository)1 BadRequestException (se.michaelthelin.spotify.exceptions.detailed.BadRequestException)1 ClientCredentials (se.michaelthelin.spotify.model_objects.credentials.ClientCredentials)1 AudioAnalysis (se.michaelthelin.spotify.model_objects.miscellaneous.AudioAnalysis)1 CurrentlyPlaying (se.michaelthelin.spotify.model_objects.miscellaneous.CurrentlyPlaying)1 CurrentlyPlayingContext (se.michaelthelin.spotify.model_objects.miscellaneous.CurrentlyPlayingContext)1 FeaturedPlaylists (se.michaelthelin.spotify.model_objects.special.FeaturedPlaylists)1 SearchResult (se.michaelthelin.spotify.model_objects.special.SearchResult)1 Album (se.michaelthelin.spotify.model_objects.specification.Album)1