

# ## 2015-06-01  NOTE TO SELF
#   This is probably exactly where the difference between get_json_from_spotify_url and get_json_from_spotify_url_OLD will matter
#   You might have to go through the git commits to see where the differences are and what the old version was actually doing regarding parsing.
#   Alternatively, now that you better understand Spotify's output, you might want to reinvestigate how to parse it


get_featured_playlists <- function(token=get_spotify_API_token(), locale=NULL, country=NULL, timestamp=NULL, limit=50, offset=0) {

## What playlists where featured will vary depending on (1) date (2) time (3) territory
## That information is all represented in the API call
## This function creates the appropriate API call based on the function parameters
##   and sends the URL to get_json_from_spotify_url to get an appropriately parsed JSON

  if (all(!nchar(country)))
    country <- NULL

  timestamp <- as.iso8601(timestamp)
  base_url <- "https://api.spotify.com/v1/browse/featured-playlists"

  stop("
    Here is where the difference between get_json_from_spotify_url & .._OLD is important
    They are saved to different locations in old and new
                                                                                      .
    Remember that for get_featured_playlists we are donwnloading the list of playlists 
       for a given date-time-country
                                                                                      .
    Save accordingly")


  url <- pasteURL(base_url, locale, country, timestamp, limit, offset)
  return(get_json_from_spotify_url(url=url, token=token, verbose=TRUE, url_type="playlists"))

}