-
-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
I'm trying to use if object.canMakeNextRequest to get all possible artists returned by getMyFollowedArtists however the second request doesn't appear to be returning an object with any items in it. I've tested my code with the getMyTopArtists method and it works properly. I've also manually changed the limit on getMyFollowedArtists to ensure that the API will return more than the default limit, and it does.
Here's a sample of my code just to see what I am doing.
var artists: PagingObject<Artist>? {
didSet {
print("Added more to artists variable.")
}
}
func grabSpotifyArtists(token: String?) {
Spartan.authorizationToken = token
Spartan.loggingEnabled = true
_ = Spartan.getMyFollowedArtists(limit: 10, after: nil, success: { (object) in
self.artists = object
self.printArtists()
self.fetchAllItems()
}, failure: { (error) in
print(error)
})
}
func fetchAllItems() {
if let artists = self.artists {
if artists.canMakeNextRequest {
artists.getNext(success: { (object) in
self.artists = object
self.printArtists()
self.fetchAllItems()
}) { (error) in
print(error)
}
}
}
}
func printArtists() {
if let artists = self.artists?.items {
for artist in artists {
print(artist.name)
}
}
}Sample output:
🔵 [AlamoRecordLogger] GET https://api.spotify.com/v1/me/following?type=artist&limit=10
⚪️ [AlamoRecordLogger] GET https://api.spotify.com/v1/me/following?type=artist&limit=10 (200 OK) 0.15 seconds
Added more to artists variable.
Optional("Handsome Furs")
Optional("Nevermen")
Optional("White Denim")
Optional("Quilt")
Optional("The Poison Control Center")
Optional("The Courtneys")
Optional("Meat Wave")
Optional("The Spook School")
Optional("Savages")
Optional("Twin Peaks")
🔵 [AlamoRecordLogger] GET https://api.spotify.com/v1/me/following?type=artist&after=1xD85sp0kecIVuMwUHShxs&limit=10
⚪️ [AlamoRecordLogger] GET https://api.spotify.com/v1/me/following?type=artist&after=1xD85sp0kecIVuMwUHShxs&limit=10 (200 OK) 0.08 seconds
Added more to artists variable.
What I'd expect to happen is the what happens if I use the getMyTopArtists method like so... changed code following way:
func grabSpotifyArtists(token: String?) {
Spartan.authorizationToken = token
Spartan.loggingEnabled = true
_ = Spartan.getMyTopArtists(limit: 10, offset: 0, timeRange: .longTerm, success: { (object) in
self.artists = object
self.printArtists()
self.fetchAllItems()
}, failure: { (error) in
print(error)
})
}Output:
🔵 [AlamoRecordLogger] GET https://api.spotify.com/v1/me/top/artists?limit=10&offset=0&time_range=long_term
⚪️ [AlamoRecordLogger] GET https://api.spotify.com/v1/me/top/artists?limit=10&offset=0&time_range=long_term (200 OK) 0.67 seconds
Added more to artists variable.
Optional("Guided By Voices")
Optional("Lana Del Rey")
Optional("Meat Wave")
Optional("YACHT")
Optional("White Denim")
Optional("Spoon")
Optional("Electric Six")
Optional("Television")
Optional("Quilt")
Optional("Savages")
🔵 [AlamoRecordLogger] GET https://api.spotify.com/v1/me/top/artists?limit=10&offset=10&time_range=long_term
⚪️ [AlamoRecordLogger] GET https://api.spotify.com/v1/me/top/artists?limit=10&offset=10&time_range=long_term (200 OK) 0.19 seconds
Added more to artists variable.
Optional("Sleater-Kinney")
Optional("Queens of the Stone Age")
Optional("Local H")
Optional("Nick Lowe")
Optional("EMA")
Optional("Kishi Bashi")
Optional("Swearin\'")
Optional("BOYTOY")
Optional("Saint Motel")
Optional("Sleigh Bells")
🔵 [AlamoRecordLogger] GET https://api.spotify.com/v1/me/top/artists?limit=10&offset=20&time_range=long_term
⚪️ [AlamoRecordLogger] GET https://api.spotify.com/v1/me/top/artists?limit=10&offset=20&time_range=long_term (200 OK) 0.19 seconds
Added more to artists variable.
Optional("HAIM")
Optional("Wampire")
Optional("White Fence")
Optional("The Spook School")
Optional("Vampire Weekend")
Optional("Wolf Alice")
Optional("Woods")
Optional("Algebra Suicide")
Optional("Foxygen")
Optional("Twin Peaks")
🔵 [AlamoRecordLogger] GET https://api.spotify.com/v1/me/top/artists?limit=10&offset=30&time_range=long_term
⚪️ [AlamoRecordLogger] GET https://api.spotify.com/v1/me/top/artists?limit=10&offset=30&time_range=long_term (200 OK) 0.18 seconds
Added more to artists variable.
Optional("Joanna Gruesome")
Optional("Chastity Belt")
Optional("The High Strung")
Optional("Metz")
Optional("Archie Bronson Outfit")
Optional("Alex Winston")
Optional("Faith No More")
Optional("Posse")
Optional("Todd Terje")
Optional("Museum Mouth")
🔵 [AlamoRecordLogger] GET https://api.spotify.com/v1/me/top/artists?limit=10&offset=40&time_range=long_term
⚪️ [AlamoRecordLogger] GET https://api.spotify.com/v1/me/top/artists?limit=10&offset=40&time_range=long_term (200 OK) 0.18 seconds
Added more to artists variable.
Optional("Andrew Bird")
Optional("Phoenix")
Optional("Evans The Death")
Optional("California X")
Optional("Nine Inch Nails")
Optional("Richard Hell")
Optional("Harry Nilsson")
Optional("FIDLAR")
Optional("Kitten")
Optional("Rockpile")
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels