Class SpotifyAdapter

java.lang.Object
yearreview.app.data.sources.audio.adapter.AudioDatabaseAdapter
yearreview.app.data.sources.audio.adapter.SpotifyAdapter

public class SpotifyAdapter extends AudioDatabaseAdapter
An Adapter to input the Spotify extended listening (that can be exported here) into the AudioDatabase.
Author:
ColdStone37
  • Field Details

    • dataPath

      private final String dataPath
      Path to the files exported from spotify.
  • Constructor Details

    • SpotifyAdapter

      public SpotifyAdapter(AudioDatabase database, XmlNode config)
      Constructs a new SpotifyAdapter with a database to use and a configuration.
      Parameters:
      database - database to insert the songs
      config - configuration for the adapter
  • Method Details

    • loadData

      public void loadData(Instant start, Instant end) throws IOException
      Loads the data from the specified path.
      Specified by:
      loadData in class AudioDatabaseAdapter
      Parameters:
      start - start time of data to load
      end - end time of data to load
      Throws:
      IOException - if the all or some of the files can't be read
    • processJsonObject

      private void processJsonObject(javax.json.JsonObject object, Instant start, Instant end)
      Processes a JsonObject from the Stream and inserts it into the database.
      Parameters:
      object - object to process
      start - start time of data to load
      end - end time of data to load
    • isBetween

      private boolean isBetween(Instant val, Instant start, Instant end)
      Tests if a time is between to Instant
      Parameters:
      val - value to test whether it lies in between
      start - start of interval to test
      end - end of interval to test
      Returns:
      true if val is between start and end, false otherwise