Package de.presti.ree6.utils.apis
Class SpotifyAPIHandler
java.lang.Object
de.presti.ree6.utils.apis.SpotifyAPIHandler
API Handler class used to work quicker and easier with the Spotify API..
Original Author: Kay-Bilger
Original Author: Kay-Bilger
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionConvert a Spotify Playlist Link into a List with all Track names.getArtistAndName(String trackID) Get the Artist and Track Name of a Track.se.michaelthelin.spotify.model_objects.specification.TrackGet the Track.ArrayList<se.michaelthelin.spotify.model_objects.specification.Track>Get the Tracks on a Playlist.voidInitialize the Spotify API.static String[]parseSpotifyURL(String spotifyURL) Parse a Spotify URL.
-
Field Details
-
instance
The Spotify API-Handler.
-
-
Constructor Details
-
SpotifyAPIHandler
public SpotifyAPIHandler()Constructor.
-
-
Method Details
-
initSpotify
public void initSpotify() throws org.apache.hc.core5.http.ParseException, se.michaelthelin.spotify.exceptions.SpotifyWebApiException, IOExceptionInitialize the Spotify API.- Throws:
org.apache.hc.core5.http.ParseException- if the response is not a Valid JSON.se.michaelthelin.spotify.exceptions.SpotifyWebApiException- if an error occurs.IOException- if there was a network error.
-
getTrack
public se.michaelthelin.spotify.model_objects.specification.Track getTrack(String trackId) throws org.apache.hc.core5.http.ParseException, se.michaelthelin.spotify.exceptions.SpotifyWebApiException, IOException Get the Track.- Parameters:
trackId- The Track ID.- Returns:
- a
TrackObject. - Throws:
org.apache.hc.core5.http.ParseException- if the response is not a Valid JSON.se.michaelthelin.spotify.exceptions.SpotifyWebApiException- if an error occurs.IOException- if there was a network error.
-
getTracks
public ArrayList<se.michaelthelin.spotify.model_objects.specification.Track> getTracks(String playlistId) Get the Tracks on a Playlist.- Parameters:
playlistId- The Playlist ID.- Returns:
- a
ListofTrackObjects.
-
getArtistAndName
public String getArtistAndName(String trackID) throws org.apache.hc.core5.http.ParseException, se.michaelthelin.spotify.exceptions.SpotifyWebApiException, IOException Get the Artist and Track Name of a Track.- Parameters:
trackID- The Track ID.- Returns:
- The Artist and Track Name.
- Throws:
org.apache.hc.core5.http.ParseException- if the response is not a Valid JSON.se.michaelthelin.spotify.exceptions.SpotifyWebApiException- if an error occurs.IOException- if there was a network error.
-
convert
public ArrayList<String> convert(String link) throws org.apache.hc.core5.http.ParseException, se.michaelthelin.spotify.exceptions.SpotifyWebApiException, IOException Convert a Spotify Playlist Link into a List with all Track names.- Parameters:
link- The Spotify Playlist Link.- Returns:
- A List with all Track names.
- Throws:
org.apache.hc.core5.http.ParseException- if the response is not a Valid JSON.se.michaelthelin.spotify.exceptions.SpotifyWebApiException- if an error occurs.IOException- if there was a network error.
-
parseSpotifyURL
Parse a Spotify URL.- Parameters:
spotifyURL- The Spotify URL.- Returns:
- The Type and ID of the URL.
-