<commit_before>
module.exports = {
  listAirPlayDevices: function (callback){
    itunes = Application('iTunes');
    airPlayDevices = itunes.airplayDevices();
    airPlayResults = [];
    for (i = 0; i < airPlayDevices.length; i++) {
      airPlayDevice = airPlayDevices[i];

      if (!airPlayDevice.networkAddress()) continue;

      deviceData = {};
      deviceData["id"] = airPlayDevice.networkAddress().replace(/:/g, '-');
      deviceData["name"] = airPlayDevice.name();
      deviceData["kind"] = airPlayDevice.kind();
      deviceData["active"] = airPlayDevice.active();
      deviceData["selected"] = airPlayDevice.selected();
      deviceData["sound_volume"] = airPlayDevice.soundVolume();
      deviceData["supports_video"] = airPlayDevice.supportsVideo();
      deviceData["supports_audio"] = airPlayDevice.supportsAudio();
      deviceData["network_address"] = airPlayDevice.networkAddress();

      airPlayResults.push(deviceData);
    }

    return airPlayResults;
  },
  setSelectionStateAirPlayDevice: function (id, selected){
    itunes = Application('iTunes');
    id = id.replace(/-/g, ':');
    foundAirPlayDevice = null;
    deviceData = {};

    airPlayDevices = itunes.airplayDevices();
    for (i = 0; i < airPlayDevices.length; i++) {
      airPlayDevice = airPlayDevices[i];

      if (airPlayDevice.networkAddress() == id){
        foundAirPlayDevice = airPlayDevice;
        break;
      }
    }

    if (foundAirPlayDevice) {
      foundAirPlayDevice.selected = selected;

      deviceData["id"] = foundAirPlayDevice.networkAddress().replace(/:/g, '-');
      deviceData["name"] = foundAirPlayDevice.name();
      deviceData["kind"] = foundAirPlayDevice.kind();
      deviceData["active"] = foundAirPlayDevice.active();
      deviceData["selected"] = foundAirPlayDevice.selected();
      deviceData["sound_volume"] = foundAirPlayDevice.soundVolume();
      deviceData["supports_video"] = foundAirPlayDevice.supportsVideo();
      deviceData["supports_audio"] = foundAirPlayDevice.supportsAudio();
      deviceData["network_address"] = foundAirPlayDevice.networkAddress();
    }

    return deviceData;
  }
}<commit_msg>add a way to set the volume of an airplay device<commit_after>
module.exports = {
  listAirPlayDevices: function (callback){
    itunes = Application('iTunes');
    airPlayDevices = itunes.airplayDevices();
    airPlayResults = [];
    for (i = 0; i < airPlayDevices.length; i++) {
      airPlayDevice = airPlayDevices[i];

      if (!airPlayDevice.networkAddress()) continue;

      deviceData = {};
      deviceData["id"] = airPlayDevice.networkAddress().replace(/:/g, '-');
      deviceData["name"] = airPlayDevice.name();
      deviceData["kind"] = airPlayDevice.kind();
      deviceData["active"] = airPlayDevice.active();
      deviceData["selected"] = airPlayDevice.selected();
      deviceData["sound_volume"] = airPlayDevice.soundVolume();
      deviceData["supports_video"] = airPlayDevice.supportsVideo();
      deviceData["supports_audio"] = airPlayDevice.supportsAudio();
      deviceData["network_address"] = airPlayDevice.networkAddress();

      airPlayResults.push(deviceData);
    }

    return airPlayResults;
  },
  setSelectionStateAirPlayDevice: function (id, selected){
    itunes = Application('iTunes');
    id = id.replace(/-/g, ':');
    foundAirPlayDevice = null;
    deviceData = {};

    airPlayDevices = itunes.airplayDevices();
    for (i = 0; i < airPlayDevices.length; i++) {
      airPlayDevice = airPlayDevices[i];

      if (airPlayDevice.networkAddress() == id){
        foundAirPlayDevice = airPlayDevice;
        break;
      }
    }

    if (foundAirPlayDevice) {
      foundAirPlayDevice.selected = selected;

      deviceData["id"] = foundAirPlayDevice.networkAddress().replace(/:/g, '-');
      deviceData["name"] = foundAirPlayDevice.name();
      deviceData["kind"] = foundAirPlayDevice.kind();
      deviceData["active"] = foundAirPlayDevice.active();
      deviceData["selected"] = foundAirPlayDevice.selected();
      deviceData["sound_volume"] = foundAirPlayDevice.soundVolume();
      deviceData["supports_video"] = foundAirPlayDevice.supportsVideo();
      deviceData["supports_audio"] = foundAirPlayDevice.supportsAudio();
      deviceData["network_address"] = foundAirPlayDevice.networkAddress();
    }

    return deviceData;
  },
  setVolumeAirPlayDevice: function (id, level){
    itunes = Application('iTunes');
    id = id.replace(/-/g, ':');
    foundAirPlayDevice = null;
    deviceData = {};

    airPlayDevices = itunes.airplayDevices();
    for (i = 0; i < airPlayDevices.length; i++) {
      airPlayDevice = airPlayDevices[i];

      if (airPlayDevice.networkAddress() == id){
        foundAirPlayDevice = airPlayDevice;
        break;
      }
    }

    if (foundAirPlayDevice) {
      foundAirPlayDevice.soundVolume = level;

      deviceData["id"] = foundAirPlayDevice.networkAddress().replace(/:/g, '-');
      deviceData["name"] = foundAirPlayDevice.name();
      deviceData["kind"] = foundAirPlayDevice.kind();
      deviceData["active"] = foundAirPlayDevice.active();
      deviceData["selected"] = foundAirPlayDevice.selected();
      deviceData["sound_volume"] = foundAirPlayDevice.soundVolume();
      deviceData["supports_audio"] = foundAirPlayDevice.supportsAudio();
      deviceData["network_address"] = foundAirPlayDevice.networkAddress();
    }

    return deviceData;
  }
}
{'fraction_non_alphanumeric': 0.14338575393154487, 'fraction_numerical': 0.0009250693802035153, 'mean_word_length': 3.813891362422084, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 3, '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': '3460629', 'n_tokens_mistral': 1592, 'n_tokens_neox': 1551, 'n_words': 247}