com.wrapper.spotify.SpotifyApi Java Examples
The following examples show how to use
com.wrapper.spotify.SpotifyApi.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpotifyPlayer.java From nanoleaf-desktop with MIT License | 6 votes |
public SpotifyPlayer(SpotifyApi spotifyApi, SpotifyEffectType defaultEffect, Color[] defaultPalette, Aurora[] auroras, SpotifyPanel panel, PanelCanvas canvas) throws UnauthorizedException, HttpRequestException, StatusCodeException { this.spotifyApi = spotifyApi; this.defaultPalette = defaultPalette.clone(); palette = defaultPalette.clone(); usingDefaultPalette = true; this.auroras = auroras; this.panel = panel; this.canvas = canvas; setEffect(defaultEffect); if (auroras != null) { enableExternalStreaming(); start(); } }
Example #2
Source File: SpotifyAudioSourceManager.java From SkyBot with GNU Affero General Public License v3.0 | 6 votes |
public SpotifyAudioSourceManager(YoutubeAudioSourceManager youtubeAudioSourceManager, DunctebotConfig.Apis config) { this.config = config; final String clientId = config.spotify.clientId; final String clientSecret = config.spotify.clientSecret; final String youtubeApiKey = config.googl; if (clientId == null || clientSecret == null || youtubeApiKey == null) { logger.error("Could not load Spotify keys"); this.spotifyApi = null; this.service = null; this.youtubeAudioSourceManager = null; } else { this.youtubeAudioSourceManager = youtubeAudioSourceManager; this.spotifyApi = new SpotifyApi.Builder() .setClientId(clientId) .setClientSecret(clientSecret) .build(); this.service = Executors.newScheduledThreadPool(2, (r) -> new Thread(r, "Spotify-Token-Update-Thread")); service.scheduleAtFixedRate(this::updateAccessToken, 0, 1, TimeUnit.HOURS); } }
Example #3
Source File: SavedShow.java From spotify-web-api-java with MIT License | 6 votes |
@Override public SavedShow createModelObject(JsonObject jsonObject) { if (jsonObject == null || jsonObject.isJsonNull()) { return null; } try { return new Builder() .setAddedAt( hasAndNotNull(jsonObject, "added_at") ? SpotifyApi.parseDefaultDate(jsonObject.get("added_at").getAsString()) : null) .setShow( hasAndNotNull(jsonObject, "show") ? new ShowSimplified.JsonUtil().createModelObject( jsonObject.getAsJsonObject("show")) : null) .build(); } catch (ParseException e) { SpotifyApi.LOGGER.log(Level.SEVERE, e.getMessage()); return null; } }
Example #4
Source File: SavedTrack.java From spotify-web-api-java with MIT License | 6 votes |
public SavedTrack createModelObject(JsonObject jsonObject) { if (jsonObject == null || jsonObject.isJsonNull()) { return null; } try { return new Builder() .setAddedAt( hasAndNotNull(jsonObject, "added_at") ? SpotifyApi.parseDefaultDate(jsonObject.get("added_at").getAsString()) : null) .setTrack( hasAndNotNull(jsonObject, "track") ? new Track.JsonUtil().createModelObject( jsonObject.getAsJsonObject("track")) : null) .build(); } catch (ParseException e) { SpotifyApi.LOGGER.log(Level.SEVERE, e.getMessage()); return null; } }
Example #5
Source File: SpotifyHandler.java From spotify-toniebox-sync with Apache License 2.0 | 6 votes |
public SpotifyApi getSpotifyApi() { if (this.spotifyApi == null) { SpotifyApi.Builder builder = new SpotifyApi.Builder() .setClientId(clientId) .setClientSecret(clientSecret) .setRedirectUri(redirectUri); if (StringUtils.isNotBlank(accessToken)) { builder.setAccessToken(accessToken); } if (StringUtils.isNotBlank(refreshToken)) { builder.setRefreshToken(refreshToken); } this.spotifyApi = builder.build(); } return spotifyApi; }
Example #6
Source File: SavedAlbum.java From spotify-web-api-java with MIT License | 6 votes |
public SavedAlbum createModelObject(JsonObject jsonObject) { if (jsonObject == null || jsonObject.isJsonNull()) { return null; } try { return new Builder() .setAddedAt( hasAndNotNull(jsonObject, "added_at") ? SpotifyApi.parseDefaultDate(jsonObject.get("added_at").getAsString()) : null) .setAlbum( hasAndNotNull(jsonObject, "album") ? new Album.JsonUtil().createModelObject( jsonObject.getAsJsonObject("album")) : null) .build(); } catch (ParseException e) { SpotifyApi.LOGGER.log(Level.SEVERE, e.getMessage()); return null; } }
Example #7
Source File: PlayHistory.java From spotify-web-api-java with MIT License | 5 votes |
public PlayHistory createModelObject(JsonObject jsonObject) { if (jsonObject == null || jsonObject.isJsonNull()) { return null; } try { return new Builder() .setTrack( hasAndNotNull(jsonObject, "track") ? new TrackSimplified.JsonUtil().createModelObject( jsonObject.getAsJsonObject("track")) : null) .setPlayedAt( hasAndNotNull(jsonObject, "played_at") ? SpotifyApi.parseDefaultDate(jsonObject.get("played_at").getAsString()) : null) .setContext( hasAndNotNull(jsonObject, "context") ? new Context.JsonUtil().createModelObject( jsonObject.getAsJsonObject("context")) : null) .build(); } catch (ParseException e) { SpotifyApi.LOGGER.log(Level.SEVERE, e.getMessage()); return null; } }
Example #8
Source File: AbstractRequest.java From spotify-web-api-java with MIT License | 5 votes |
public BT setPathParameter(final String name, final String value) { assert (name != null && value != null); assert (!name.equals("") && !value.equals("")); String encodedValue = null; try { encodedValue = URLEncoder.encode(value, "UTF-8"); } catch (UnsupportedEncodingException e) { SpotifyApi.LOGGER.log(Level.SEVERE, e.getMessage()); } listAddOnce(this.pathParameters, new BasicNameValuePair(name, encodedValue)); return self(); }
Example #9
Source File: AbstractRequest.java From spotify-web-api-java with MIT License | 5 votes |
protected AbstractRequest(Builder<T, ?> builder) { assert (builder != null); assert (builder.path != null); assert (!builder.path.equals("")); this.httpManager = builder.httpManager; URIBuilder uriBuilder = new URIBuilder(); uriBuilder .setScheme(builder.scheme) .setHost(builder.host) .setPort(builder.port) .setPath(builder.path); if (builder.queryParameters.size() > 0) { uriBuilder .setParameters(builder.queryParameters); } try { this.uri = uriBuilder.build(); } catch (URISyntaxException e) { SpotifyApi.LOGGER.log(Level.SEVERE, e.getMessage()); } this.headers = builder.headers; this.contentType = builder.contentType; this.body = builder.body; this.bodyParameters = builder.bodyParameters; }
Example #10
Source File: ClientCredentialsRequest.java From spotify-web-api-java with MIT License | 5 votes |
/** * The request build method. * * @return A {@link ClientCredentialsRequest}. */ public ClientCredentialsRequest build() { setContentType(ContentType.APPLICATION_FORM_URLENCODED); setHost(SpotifyApi.DEFAULT_AUTHENTICATION_HOST); setPort(SpotifyApi.DEFAULT_AUTHENTICATION_PORT); setScheme(SpotifyApi.DEFAULT_AUTHENTICATION_SCHEME); setPath("/api/token"); return new ClientCredentialsRequest(this); }
Example #11
Source File: AuthorizationCodeRequest.java From spotify-web-api-java with MIT License | 5 votes |
/** * The request build method. * * @return An {@link AuthorizationCodeRequest}. */ public AuthorizationCodeRequest build() { setContentType(ContentType.APPLICATION_FORM_URLENCODED); setHost(SpotifyApi.DEFAULT_AUTHENTICATION_HOST); setPort(SpotifyApi.DEFAULT_AUTHENTICATION_PORT); setScheme(SpotifyApi.DEFAULT_AUTHENTICATION_SCHEME); setPath("/api/token"); return new AuthorizationCodeRequest(this); }
Example #12
Source File: AuthorizationCodeRefreshRequest.java From spotify-web-api-java with MIT License | 5 votes |
/** * The request build method. * * @return An {@link AuthorizationCodeRefreshRequest}. */ public AuthorizationCodeRefreshRequest build() { setContentType(ContentType.APPLICATION_FORM_URLENCODED); setHost(SpotifyApi.DEFAULT_AUTHENTICATION_HOST); setPort(SpotifyApi.DEFAULT_AUTHENTICATION_PORT); setScheme(SpotifyApi.DEFAULT_AUTHENTICATION_SCHEME); setPath("/api/token"); return new AuthorizationCodeRefreshRequest(this); }
Example #13
Source File: AuthorizationCodeUriRequest.java From spotify-web-api-java with MIT License | 5 votes |
/** * The request build method. * * @return An {@link AuthorizationCodeUriRequest}. */ public AuthorizationCodeUriRequest build() { setHost(SpotifyApi.DEFAULT_AUTHENTICATION_HOST); setPort(SpotifyApi.DEFAULT_AUTHENTICATION_PORT); setScheme(SpotifyApi.DEFAULT_AUTHENTICATION_SCHEME); setPath("/authorize"); return new AuthorizationCodeUriRequest(this); }
Example #14
Source File: PlaylistTrack.java From spotify-web-api-java with MIT License | 4 votes |
public PlaylistTrack createModelObject(JsonObject jsonObject) { if (jsonObject == null || jsonObject.isJsonNull()) { return null; } try { IPlaylistItem track = null; if (hasAndNotNull(jsonObject, "track")) { final JsonObject trackObj = jsonObject.getAsJsonObject("track"); if (hasAndNotNull(trackObj, "type")) { String type = trackObj.get("type").getAsString().toLowerCase(); if (type.equals("track")) { track = new Track.JsonUtil().createModelObject(trackObj); } else if (type.equals("episode")) { track = new Episode.JsonUtil().createModelObject(trackObj); } } } return new Builder() .setAddedAt( hasAndNotNull(jsonObject, "added_at") ? SpotifyApi.parseDefaultDate(jsonObject.get("added_at").getAsString()) : null) .setAddedBy( hasAndNotNull(jsonObject, "added_by") ? new User.JsonUtil().createModelObject( jsonObject.get("added_by").getAsJsonObject()) : null) .setIsLocal( hasAndNotNull(jsonObject, "is_local") ? jsonObject.get("is_local").getAsBoolean() : null) .setTrack(track) .build(); } catch (ParseException e) { SpotifyApi.LOGGER.log(Level.SEVERE, e.getMessage()); return null; } }
Example #15
Source File: SpotifyAudioSourceManager.java From kyoko with MIT License | 4 votes |
public SpotifyAudioSourceManager(SpotifyCredentials credentials, YoutubeAudioSourceManager youtubeManager) { this.api = SpotifyApi.builder().setClientId(credentials.id).setClientSecret(credentials.secret).build(); this.youtubeManager = youtubeManager; this.loaders = Arrays.asList(this::getSpotifyTrack, this::getSpotifyAlbum, this::getSpotifyPlaylist); }
Example #16
Source File: SpotifyPlaylistImporter.java From data-transfer-project with Apache License 2.0 | 4 votes |
public SpotifyPlaylistImporter(Monitor monitor, SpotifyApi spotifyApi) { this.monitor = monitor; this.spotifyApi = spotifyApi; }
Example #17
Source File: SpotifyPlaylistExporter.java From data-transfer-project with Apache License 2.0 | 4 votes |
public SpotifyPlaylistExporter(Monitor monitor, SpotifyApi spotifyApi) { this.monitor = monitor; this.spotifyApi = spotifyApi; }
Example #18
Source File: SpotifyAuthenticator.java From nanoleaf-desktop with MIT License | 4 votes |
public SpotifyApi getSpotifyApi() { return spotifyApi; }