Esempio n. 1
0
  public List<Track> searchForTrack(String query, String orderBy, int page, int locationId)
      throws SpotifyApiException {
    SpotifyTrackSearchContainer tracks = searchSpotify(query, page);
    List<String> spotifyIds = new ArrayList<String>();

    for (SpotifyTrack track : tracks.getTracks()) { // Save tracks to db
      long length = (long) track.getLength() * 1000;
      data.saveSong(track.getHref(), track.getName(), track.concatArtistNames(), length);
      // logger.debug("Found - "+track.getName()+" id: "+track.getHref());
      spotifyIds.add(track.getHref());
    }
    if (spotifyIds.size() > 0) {
      return data.getSongs(spotifyIds, locationId, orderBy);
    } else { // to prevent sql-error when there are no ids.
      return new ArrayList<Track>();
    }
  }
Esempio n. 2
0
 public List<Track> getSongs(int from, int num, String orderBy, long notPlayedIn, int locationId) {
   int to = from + Math.abs(num);
   Timestamp notPlayedSince = new Timestamp(System.currentTimeMillis() - notPlayedIn);
   return data.getSongs(locationId, from, to, orderBy, notPlayedSince);
 }