title: SPAlbumBrowse - Getting an Accurate List Of An Artist's Albums
body: <p>Okay. This is getting crazy. I've been working on this for a few days trying different weird things. I think I had a nightmare last night about libSpotify, might be a product of my sleeping habits, but, I digress.</p>
  
  <p>Anyway. Let's look up the artist "The XX" with the following code. Assume that <em>artist</em> is initialized with the artist "the xx", Spotify url spotify:artist:3iOvXCl6edW5Um0fXEBRXy</p>
  
  <pre><code>artistBrowse = [[SPArtistBrowse alloc] initWithArtist: artist inSession: spotifySession type: SP_ARTISTBROWSE_ALBUMS];
  
  [SPAsyncLoading waitUntilLoaded: artistBrowse timeout: kSPAsyncLoadingDefaultTimeout then:^(NSArray *loadedItems, NSArray *notLoadedItems) {
      [SPAsyncLoading waitUntilLoaded: artistBrowse.albums timeout: kSPAsyncLoadingDefaultTimeout then:^(NSArray *loadedItems, NSArray *notLoadedItems) {
          NSArray *types = @[@"a", @"s", @"c", @"u"];
          for(SPAlbum *album in loadedItems) {
              NSLog(@"%@, %@, %@, %d, %-50s, %@", types[album.type], album.available ? @"Y" : @" N", album.artist.name, album.year, album.name.UTF8String, album.spotifyURL);
          }
      }]; 
  }];
  </code></pre>
  
  <p>Here's the output. Sorry, it's kind of lengthy. Note that the first column refers to the SP_ALBUM_TYPE of the album (a = album, s = single, c = compilation, u = unknown), the second column is a Y or N depending on if the album is available in my session's region (US), the third column is the artist name, the fifth is the album's year, the sixth is the album's name, and lastly the Spotify URL of the album.</p>
  
  <pre><code>u, N, The xx                   , 2012, Coexist                                           , spotify:album:2cRMVS71c49Pf5SnIlJX3U
  u, N, The xx                   , 2009, xx                                                , spotify:album:2rmMeEq5D1Bg7YFRwtHBDr
  a, N, The xx                   , 2009, xx                                                , spotify:album:2nXJkqkS1tIKIyhBcFMmwz
  s, Y, The xx                   , 2013, Reunion (Edu Imbernon Remix)                      , spotify:album:4GRHNZJ1dWCqgWfiyyJF2L
  u, N, The xx                   , 2013, Fiction                                           , spotify:album:4fUxANSrGWQlRtF2kpxo6g
  s, Y, The xx                   , 2013, Innervisions Remixes                              , spotify:album:4ZmviA6XFr2D2Bfw0bicwa
  s, Y, The xx                   , 2013, Sunset (Jamie Jones Remix)                        , spotify:album:1XlsTZcDbHQmLr3tNvuV5o
  s, Y, The xx                   , 2013, Sunset (Kim Ann Foxman Remix)                     , spotify:album:26gAjcYx9iGrOuplES6jC1
  s, Y, The xx                   , 2012, Angels                                            , spotify:album:7kuu8alOjlFTGJmwsRINz9
  s, Y, The xx                   , 2012, Angels (Four Tet Remix)                           , spotify:album:4ZLWktgv4GJSgzzskz6rpI
  s, Y, The xx                   , 2012, Chained (John Talabot and Pional Blinded Remix)   , spotify:album:2PsFbWSt7nAwZuO6M6zeMU
  s, Y, The xx                   , 2012, Chained (LIAR Remix)                              , spotify:album:6HrD4wpVXVfXkZP1gxcKyH
  s, Y, The xx                   , 2012, Jamie xx Edits                                    , spotify:album:33UOrxCqUHQDH3XvNEYWoP
  s, N, The xx                   , 2009, Basic Space                                       , spotify:album:0LusnqOZqR8IYXHWE3DSQI
  s, N, The xx                   , 2009, Basic Space                                       , spotify:album:6aStvQrltK28rgDFsyOsBS
  s, Y, The xx                   , 2009, Crystalised                                       , spotify:album:6npsIAD3tolsM1htkmCDpT
  s, N, The xx                   , 2009, Islands                                           , spotify:album:7rW7Zf8fTJT25wMo4z6ww3
  s, N, The xx                   , 2009, Islands                                           , spotify:album:0KVBiUIqhl087FgJyvr8kS
  s, N, The xx                   , 2009, VCR                                               , spotify:album:0eRJD5ey3HqIgsGheUwZqg
  s, Y, The xx                   , 2009, VCR (Four Tet Remix)                              , spotify:album:0L1Dg07wMBxRkzO5qlN1li
  s, N, The xx                   , 2009, xx                                                , spotify:album:0z6ErTRiEcAML2IPrkWI5W
  a, N, Various Artists          , 2013, Circus HalliGalli                                 , spotify:album:0SCDZwyv5MbWsCdmeRHJUb
  a, N, Craig Armstrong          , 2013, The Orchestral Score From Baz Luhrmann's Film The Great Gatsby, spotify:album:7hTAlVO7LPTI5Q3KI5rTkR
  a, Y, Craig Armstrong          , 2013, The Orchestral Score From Baz Luhrmann's Film The Great Gatsby, spotify:album:6OuywehyzlNMYklKnPpr1W
  a, N, Various Artists          , 2013, Ministry Of Sound Chillout Sessions Classics      , spotify:album:4yfIS04c7NLu20GEx0fKLm
  a, N, Various Artists          , 2013, Young Folks                                       , spotify:album:56HMwAOWW0jnAH7J1S71Q1
  a, N, Various Artists          , 2013, Dance Anthems (Summer Edition 2013)               , spotify:album:25uYDaqMIFjCSKKWgDpDuM
  a, N, Various Artists          , 2013, FluxFM - Popkultur kompakt Vol. 1                 , spotify:album:44OoPqLioRdPtG181OSWXO
  a, Y, Various Artists          , 2013, Music From Baz Luhrmann's Film The Great Gatsby   , spotify:album:0ke0VwcET1D6neauEyk4U4
  a, Y, Various Artists          , 2013, Music From Baz Luhrmann's Film The Great Gatsby   , spotify:album:1ApOUkhympslVqgf9QFHUj
  a, Y, Various Artists          , 2013, Music From Baz Luhrmann's Film The Great Gatsby   , spotify:album:4fPvaODSSdvvP7nuVKCYW2
  a, N, Various Artists          , 2013, Music From Baz Luhrmann's Film The Great Gatsby   , spotify:album:0WXuzb6XoO21qOswVOH0xG
  a, N, Various Artists          , 2013, Music From Baz Luhrmann's Film The Great Gatsby   , spotify:album:2XVXltseIMrGuK09ck7TpS
  a, N, Various Artists          , 2013, Music From Baz Luhrmann's Film The Great Gatsby   , spotify:album:4zmVotzGvedZLgLt7b9enu
  a, N, Various Artists          , 2013, De Afrekening 54                                  , spotify:album:5v4Mk83IAaZF8v2ZJlR3zJ
  a, N, Various Artists          , 2013, Ministry of Sound FUT.UR.ISM                      , spotify:album:2oliIwXGnek066NvzFOyMh
  a, N, Various Artists          , 2013, Dermot O'Leary Presents The Saturday Sessions 2013, spotify:album:0vxrNQhxXzFHDoDe8ujfmC
  a, N, Various Artists          , 2013, Dermot O'Leary Presents The Saturday Sessions 2013, spotify:album:4IjdYP8ejVAUVhYEHIxV69
  a, N, Various Artists          , 2013, Switch 21                                         , spotify:album:2asHAel3cC4en0vj8OvL14
  a, N, Various Artists          , 2013, BRIT Awards 2013                                  , spotify:album:42DRlqFzejkEI1wTjggazF
  a, N, Various Artists          , 2013, about:berlin vol:2                                , spotify:album:2M4eESAbUIRLtcoTZWKSwd
  a, N, Various Artists          , 2012, De Afrekening 53 - Best Of 2012                   , spotify:album:3EZr5R7qYv49m80jTjjURV
  a, N, Various Artists          , 2012, Thank God It's Friday                             , spotify:album:0uUKY9EW6pQN8SPzU9vUyd
  a, N, Various Artists          , 2012, Humo 2012                                         , spotify:album:3JUslyKt2lAhaQdwX2nsCu
  a, N, Various Artists          , 2012, FM4 Soundselection Vol.27                         , spotify:album:6vWWIRMgDoy3bYkX6oYy6j
  a, N, Various Artists          , 2012, Ministry of Sound Chillout Sessions XV            , spotify:album:1luLiZ8M8yvlwwaLZNkBxI
  a, N, Various Artists          , 2012, Life Is Music 2012/2                              , spotify:album:5uobOKU5V5Gdkr89uioVSk
  a, N, Various Artists          , 2012, Pure FM Vol.3 - Best Of 2012                      , spotify:album:6VZUAizoJYpXS614EhuErD
  a, N, Various Artists          , 2012, Festivalitis                                      , spotify:album:1Wzv0KyuSgZhXJTVSHuZMR
  a, N, Various Artists          , 2012, Sonar 1000 Vol.2                                  , spotify:album:6RygdphSUzqmQI0tY0XTC8
  a, N, Various Artists          , 2012, We Love Real Music                                , spotify:album:3YTlHLpLTpAPYzkh05iewe
  a, N, Various Artists          , 2012, Alle 40 Goed: Alternative                         , spotify:album:2v7n6Lgf0IV3bWqsxczFYO
  a, N, Various Artists          , 2012, Alle 40 Goed: Alternative                         , spotify:album:3Xy2qnFEUNjHMXAF3AlHhD
  a, N, The Antlers              , 2011, Together                                          , spotify:album:5k6JBXhKxclnxOtGtvpxXP
  a, N, Various Artists          , 2011, Radio 1 Sonar 1000                                , spotify:album:0ZiepVOAQGrWIl7AeUUsEy
  a, N, Various Artists          , 2011, Ministry of Sound Uncovered 3                     , spotify:album:31Ut6kXlaSoADr5k52rYQb
  a, N, Various Artists          , 2011, The Weather Channel Presents ‚Äì The Sounds Of Winter, spotify:album:3TWTfxuFaMCcQMHomKRTpN
  a, N, Various Artists          , 2011, Solid Sounds 2011/1                               , spotify:album:46lwy99LsDyubeZU2KK5kB
  a, N, Various Artists          , 2010, Humo's Top 2010                                   , spotify:album:6Cvt2RPh9ANl4CUMXGSFHu
  a, N, Various Artists          , 2010, Ministry Of Sound Chillout Sessions XIII          , spotify:album:2ze7hxcYnwo4CpdyK63xGQ
  a, Y, The Big Pink             , 2010, Tapes                                             , spotify:album:1RW3Hq6dTHn1Phur2dRvg3
  c, Y, The Big Pink             , 2010, Tapes                                             , spotify:album:2GJplTNzOUot6it93FtfLu
  a, N, Mario Basanov            , 2010, Future Balearica: New Chill &amp; Warm Sunset Sounds  , spotify:album:0I3COq9K4saT03qXsCmq6c
  a, N, Various Artists          , 2010, Volume.at - Alternative Summer 2010               , spotify:album:5juF4xi88AVJCreQCdm319
  a, N, Various Artists          , 2010, Festivalguide 2010                                , spotify:album:3B066qff9ZcbFuFWC4vYai
  a, N, Various Artists          , 2010, Life Is Music 2010-1                              , spotify:album:2jsGbNXBbjI933cmL9kGms
  a, N, Various Artists          , 2010, Uncovered 2                                       , spotify:album:3TEnNtbEnahNSkmcp0xQFZ
  a, N, Various Artists          , 2010, Various Artists/Rough Trade Counter Culture 09    , spotify:album:0KRR3PXLfJlIccrlgAllBh
  </code></pre>
  
  <p>Out of this data, I want to extract something like the following. These are the xx's albums on their artist page the official Spotify desktop client with the same account I'm using to log into libSpotify with.</p>
  
  <p><img src="https://i.stack.imgur.com/7frlX.png" alt=""></p>
  
  <p>Note that in the output, even after I've loaded all of the albums from artistBrowse.albums, the two items that are actual albums available in my region are <em>all</em> listed as unavailable, and only one is actual listed as an album. </p>
  
  <pre><code>u, N, The xx                   , 2012, Coexist                                           , spotify:album:2cRMVS71c49Pf5SnIlJX3U
  u, N, The xx                   , 2009, xx                                                , spotify:album:2rmMeEq5D1Bg7YFRwtHBDr
  a, N, The xx                   , 2009, xx                                                , spotify:album:2nXJkqkS1tIKIyhBcFMmwz
  </code></pre>
  
  <p>How do I solve this problem? Lots of times, if you go and check the web-api with the Spotify URLs of albums that say they're not available in my region through album.available, the "US" region code is right in the output from the album's result page from the web-api. Secondly, I get WIDELY different results all of the time. Nothing's consistent, sometimes Red Hot Chili Peppers' album "I'm With You" shows up as available in my region, sometimes there isn't one that is available in my region. If there are albums that are not available in my region, sometimes calling another <em>waitUntiLoaded:</em> call with the <em>loadedItems</em> returned in the <em>waitUntilLoaded</em> call with artistBrowse.albums solves the issue; loading the "loaded items" again alleviates the issue occasionally? That doesn't even make sense.</p>
  
  <p>Lastly, wtf.</p>
  
  <pre><code>a, N, Rihanna                  , 2012, Unaplogetic                                       , spotify:album:4owyFvp5H3UXKIOBBT9x3m
  a, Y, Rihanna                  , 2012, Unapologetic                                      , spotify:album:0XJya16l3K1J2dEwY19F8z
  a, Y, Rihanna                  , 2012, Unapologetic                                      , spotify:album:4eddbruVtOqw8khwxSH6H2
  a, N, Rihanna                  , 2012, Unapologetic                                      , spotify:album:4XBfFj0WYyh5mBtU61EdyY
  a, N, Rihanna                  , 2012, Unapologetic                                      , spotify:album:5pLlGJrxuQO3jMoQe1XxZY
  a, N, Rihanna                  , 2012, Unapologetic                                      , spotify:album:0giyQojM6DkyXVYigNo72p
  a, Y, Rihanna                  , 2012, Unapologetic                                      , spotify:album:1ciAVKFdlpLi2eGDlXv6Bo
  a, N, Rihanna                  , 2012, Unapologetic                                      , spotify:album:1jlYso6n0IxsGTLIvZOXUn
  a, N, Rihanna                  , 2012, Unapologetic                                      , spotify:album:5UDXzVwWnn3mDy3mTpQPYb
  </code></pre>
  
  <p><strong>HELP</strong> please, this is a huge bummer. I am literally at a total loss here on how to go about getting <em>any</em> sort of reliable list, though I'm convinced that if the official client can do it, then I can too. I've been staring at this for so many days I'm thinking about backing up my search with a call to the web-api and like, using the web-api to give me album lists for artists.... sounds really unpleasant though. Otherwise, the library has been quite a joy to work with. Thanks again for your help!</p>