Class SpotifyAPIHandler

java.lang.Object
de.presti.ree6.utils.apis.SpotifyAPIHandler

public class SpotifyAPIHandler extends Object
API Handler class used to work quicker and easier with the Spotify API..
Original Author: Kay-Bilger
  • Field Details

  • Constructor Details

    • SpotifyAPIHandler

      public SpotifyAPIHandler()
      Constructor.
  • Method Details

    • initSpotify

      public void initSpotify() throws org.apache.hc.core5.http.ParseException, se.michaelthelin.spotify.exceptions.SpotifyWebApiException, IOException
      Initialize 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 Track Object.
      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 List of Track Objects.
    • 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

      public static String[] parseSpotifyURL(String spotifyURL)
      Parse a Spotify URL.
      Parameters:
      spotifyURL - The Spotify URL.
      Returns:
      The Type and ID of the URL.