<commit_before>require([
  '$api/models',
  '$api/search#Search'
], function (models, Search) {

  var base = 'http://api.tumblr.com/v2/';
  var apiKey = '<KEY>';

  var loadFriends = function (blogNames, callback) {
    var datas = [];
    blogNames.forEach(function (blogName) {
      $.get(base + 'blog/' + blogName + '/info?api_key=' + apiKey, function (data) {
        datas.push(data.response.blog);
        if (datas.length === blogNames.length) {
          callback(datas);
        }
      });
    });
  };

  var trackListing = function (blogName, callback) {

    // Get the blog info
    $.get(base + 'blog/' + blogName + '.tumblr.com/info?api_key=' + apiKey, function (data) {

      var blog = data.response.blog;

      // Grab songs and find on spotify
      $.get(base + 'blog/' + blogName + '.tumblr.com/posts?type=audio&limit=50&api_key=' + apiKey, function (postData) {

          var uris = [];
          var pending = postData.response.posts.length;
          postData.response.posts.forEach(function (post) {

            // FAIL
            if (! post.track_name) {
              pending -= 1;
              return;
            }

            var searcher = Search.search(post.track_name + '  ' + post.artist);
            searcher.tracks.snapshot({ length: 1 }).done(function (t) {

              if (t.length > 0) { uris.push(t._uris[0]); } // add result

              pending -= 1;
              if (pending === 0) {
                callback(data.response.blog, uris);
              }

            });

          });

        });

      });

  };

  exports.loadFriends = loadFriends;
  exports.trackListing = trackListing;

});
<commit_msg>USe source urls if we have them<commit_after>require([
  '$api/models',
  '$api/search#Search'
], function (models, Search) {

  var base = 'http://api.tumblr.com/v2/';
  var apiKey = '<KEY>';

  var loadFriends = function (blogNames, callback) {
    var datas = [];
    blogNames.forEach(function (blogName) {
      $.get(base + 'blog/' + blogName + '/info?api_key=' + apiKey, function (data) {
        datas.push(data.response.blog);
        if (datas.length === blogNames.length) {
          callback(datas);
        }
      });
    });
  };

  var trackListing = function (blogName, callback) {

    // Get the blog info
    $.get(base + 'blog/' + blogName + '.tumblr.com/info?api_key=' + apiKey, function (data) {

      var blog = data.response.blog;

      // Grab songs and find on spotify
      $.get(base + 'blog/' + blogName + '.tumblr.com/posts?type=audio&limit=50&api_key=' + apiKey, function (postData) {

          var uris = [];
          var pending = postData.response.posts.length;
          postData.response.posts.forEach(function (post) {

            // FAIL
            if (! post.track_name) {
              if (!(pending -= 1)) { callback(data.response.blog, uris); }
              return;
            }

            // do we already have the URI?
            if (post.source_title === 'Spotify') {
              var m = post.source_url.match(/track\/(\w+)/);
              if (m) {
                uris.push('spotify:track:' + m[1]);
                if (!(pending -= 1)) { callback(data.response.blog, uris); }
                return;
              }
            }

            var searcher = Search.search(post.track_name + '  ' + post.artist);
            searcher.tracks.snapshot({ length: 1 }).done(function (t) {
              if (t.length > 0) { uris.push(t._uris[0]); } // add result
              if (!(pending -= 1)) { callback(data.response.blog, uris); }
            });

          });

        });

      });

  };

  exports.loadFriends = loadFriends;
  exports.trackListing = trackListing;

});

{'fraction_non_alphanumeric': 0.15955723542116632, 'fraction_numerical': 0.0051295896328293735, 'mean_word_length': 1.8632148377125193, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4792945', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1127, 'n_words': 237}