Search in sources :

Example 11 with ParseException

use of org.apache.hc.core5.http.ParseException in project spotify-web-api-java by spotify-web-api-java.

the class RemoveItemsFromPlaylistExample method removeItemsFromPlaylist_Sync.

public static void removeItemsFromPlaylist_Sync() {
    try {
        final SnapshotResult snapshotResult = removeItemsFromPlaylistRequest.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 12 with ParseException

use of org.apache.hc.core5.http.ParseException in project spotify-web-api-java by spotify-web-api-java.

the class SearchItemExample method searchItem_Sync.

public static void searchItem_Sync() {
    try {
        final SearchResult searchResult = searchItemRequest.execute();
        System.out.println("Total tracks: " + searchResult.getTracks().getTotal());
    } catch (IOException | SpotifyWebApiException | ParseException e) {
        System.out.println("Error: " + e.getMessage());
    }
}
Also used : SearchResult(se.michaelthelin.spotify.model_objects.special.SearchResult) IOException(java.io.IOException) ParseException(org.apache.hc.core5.http.ParseException) SpotifyWebApiException(se.michaelthelin.spotify.exceptions.SpotifyWebApiException)

Example 13 with ParseException

use of org.apache.hc.core5.http.ParseException in project spotify-web-api-java by spotify-web-api-java.

the class GetAudioAnalysisForTrackExample method getAudioAnalysisForTrack_Sync.

public static void getAudioAnalysisForTrack_Sync() {
    try {
        final AudioAnalysis audioAnalysis = getAudioAnalysisForTrackRequest.execute();
        System.out.println("Track duration: " + audioAnalysis.getTrack().getDuration());
    } catch (IOException | SpotifyWebApiException | ParseException e) {
        System.out.println("Error: " + e.getMessage());
    }
}
Also used : AudioAnalysis(se.michaelthelin.spotify.model_objects.miscellaneous.AudioAnalysis) IOException(java.io.IOException) ParseException(org.apache.hc.core5.http.ParseException) SpotifyWebApiException(se.michaelthelin.spotify.exceptions.SpotifyWebApiException)

Example 14 with ParseException

use of org.apache.hc.core5.http.ParseException 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 15 with ParseException

use of org.apache.hc.core5.http.ParseException 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)

Aggregations

ParseException (org.apache.hc.core5.http.ParseException)62 IOException (java.io.IOException)54 SpotifyWebApiException (se.michaelthelin.spotify.exceptions.SpotifyWebApiException)33 CloseableHttpResponse (org.apache.hc.client5.http.impl.classic.CloseableHttpResponse)24 HttpPost (org.apache.hc.client5.http.classic.methods.HttpPost)13 HttpGet (org.apache.hc.client5.http.classic.methods.HttpGet)12 CloseableHttpClient (org.apache.hc.client5.http.impl.classic.CloseableHttpClient)11 HttpEntity (org.apache.hc.core5.http.HttpEntity)10 HashMap (java.util.HashMap)8 Map (java.util.Map)6 StringEntity (org.apache.hc.core5.http.io.entity.StringEntity)6 BasicNameValuePair (org.apache.hc.core5.http.message.BasicNameValuePair)6 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)5 ArrayList (java.util.ArrayList)5 ClassicHttpResponse (org.apache.hc.core5.http.ClassicHttpResponse)5 Matcher (java.util.regex.Matcher)4 UrlEncodedFormEntity (org.apache.hc.client5.http.entity.UrlEncodedFormEntity)4 AuthorizationCodeCredentials (se.michaelthelin.spotify.model_objects.credentials.AuthorizationCodeCredentials)4 AudioTrack (com.sedmelluq.discord.lavaplayer.track.AudioTrack)3 List (java.util.List)3