<commit_before>var API = function() {
  // override jQuery xhr
  jQuery.ajaxSettings.xhr = function() {
    try {
      return new XMLHttpRequest({mozSystem: true});
    } catch(e) {}
  };

  this.encodeQueue = [];
  this.playlist = [];
  this.playlistSize = 0;
  this.apiEndpoint = "http://52.68.23.123/cgi-bin/convert.py";
};

API.prototype = {
  initProperties: function() {
    this.encodeQueue = [];
    this.playlist = [];
    this.playlistSize = 0;
  },
  initWithTerm: function(term) {
    this.initProperties();
    this.fetchPreviewJSON(term)
    .then(this.parseJSON.bind(this))
    .then(this.startConvert.bind(this));
  },

  // sequential convert
  startConvert: function() {
  },

  parseJSON: function(data) {
    this.playlistSize = data.resultCount;
    data.results.forEach(function(item){
      this.encodeQueue.push({
        title:  item.trackName,
        album:  item.collectionName,
        artist: item.artistName,
        trackUrl: item.trackViewUrl,
        m4aUrl: item.previewUrl,
        mp3Url: null,
        artworkUrl: item.artworkUrl100.replace("100x100-75.jpg", "400x400-75.jpg")
      });
    }.bind(this));
  },

  // API request
  fetchPreviewJSON: function(term) {
    // iTunes APIからJSONを取得してパース<commit_msg>startConvertはよくない名前<commit_after>var API = function() {
  // override jQuery xhr
  jQuery.ajaxSettings.xhr = function() {
    try {
      return new XMLHttpRequest({mozSystem: true});
    } catch(e) {}
  };

  this.encodeQueue = [];
  this.playlist = [];
  this.playlistSize = 0;
  this.apiEndpoint = "http://192.168.3.11/cgi-bin/convert.py";
};

API.prototype = {
  initProperties: function() {
    this.encodeQueue = [];
    this.playlist = [];
    this.playlistSize = 0;
  },
  initWithTerm: function(term) {
    this.initProperties();
    this.fetchPreviewJSON(term)
    .then(this.parseJSON.bind(this))
    .then(this.prefetch.bind(this));
  },

  prefetch: function() {
  },

  parseJSON: function(data) {
    this.playlistSize = data.resultCount;
    data.results.forEach(function(item){
      this.encodeQueue.push({
        title:  item.trackName,
        album:  item.collectionName,
        artist: item.artistName,
        trackUrl: item.trackViewUrl,
        m4aUrl: item.previewUrl,
        mp3Url: null,
        artworkUrl: item.artworkUrl100.replace("100x100-75.jpg", "400x400-75.jpg")
      });
    }.bind(this));
  },

  // API request
  fetchPreviewJSON: function(term) {
    // iTunes APIからJSONを取得してパース
{'fraction_non_alphanumeric': 0.14898785425101216, 'fraction_numerical': 0.025910931174089068, 'mean_word_length': 2.8609375, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1480960', 'n_tokens_mistral': 891, 'n_tokens_neox': 834, 'n_words': 127}