Die drei ??? on Spotify

Since April 1. 2016 many episodes of the popular German series Die drei ??? are available for free on Spotify. Unfortunately Spotify doesn’t list the albums in a structured way.

Screenshot Die drei ??? on Spotify
Spotify screenshot: It’s hard to get an overview about the available episodes, since you can’t sort them by name.

Spotify has a well working API including a URL that returns all albums of an artist in JSON format. For Die drei ??? that is:

https://api.spotify.com/v1/artists/3meJIgRw7YleJrmbpbJK6S/albums

That made it easy to write a little website listing all available episodes in a clean way. Update (May 2017): Spotify has changed their API access rules in a way that requires an authentication prior to fetching the list of albums. See Spotify’s Web API Authorization Guide for more details.

In order to download all albums of a given artist I developed a module which I’ll post here, because it is the core of the app.

var api = (function() {
  var spotifyDataUrl = 'https://api.spotify.com/v1/artists/3meJIgRw7YleJrmbpbJK6S/albums';

  var downloaded = []; // spotify API serves only limited number of entries at once

  function fetchData(callback) {
    request(callback, 0);
  }

  function request(callback, offset) {
    var jqxhr = jQuery.getJSON(spotifyDataUrl + '?offset=' + offset)
      .done(function(data) {
        downloaded = downloaded.concat(data.items);
        NProgress.set(downloaded.length / data.total);
        if (downloaded.length >= data.total || 
          data.offset + data.limit > data.total) 
        {
          callback(null, downloaded);
        }
        else {
          request(callback, data.offset + data.limit);
        }
      }).fail(function(err) {
        callback(err);
      });
  }

  return {
    fetchData: fetchData
  };
})();

The ordered list of all episodes can be found at my website.

The code of the above-mentioned site is open source and has been uploaded to GitHub here.

Screenshot Die drei ??? web-tool

(69 Posts)
Zürich-based Software Engineer with Google and Founder of Denk Development. Opinions are my own. I am interested in data science, software engineering, 3d-printing, arts, music, microcontrollers, and sports.
View all author’s posts