<commit_before>begin
  require 'appscript'
rescue LoadError => e
  raise LoadError.new("#{e.message} -- Please try: gem install rb-appscript")
end

class Anyplayer::ItunesMac < Anyplayer::Player
  def playpause
    app.playpause
  end

  def play
    app.play
  end

  def pause
    app.pause
  end

  def prev
    app.previous_track
    super
  end

  def next
    app.next_track
    super
  end

  def voldown
    app.sound_volume.set(volume + 10)
  end

  def volup
    app.sound_volume.set(volume + 10)
  end

  def volume
    app.sound_volume.get
  end

  def track
    app.current_track.name.get
  end

  def artist
    app.current_track.artist.get
  end

  def album
    app.current_track.album.get
  end

  def launched?
    Appscript.app('System Events').processes.name.get.include?("iTunes") and app
  end

  def name
    "iTunes"
  end

  private

    def app
      @app ||= Appscript.app('iTunes')
    end
end<commit_msg>iTunes Mac use command line osascript instead of 'appscript' gem<commit_after>class Anyplayer::ItunesMac < Anyplayer::Player
  def playpause
    tell_to 'playpause'
  end

  def prev
    tell_to 'previous track'
  end

  def next
    tell_to 'next track'
  end

  def voldown
    tell_to 'set sound volume to sound volume - 10'
  end

  def volup
    tell_to 'set sound volume to sound volume + 10'
  end

  def volume
    tell_to 'return sound volume'
  end

  def track
    tell_to 'return name of current track'
  end

  def artist
    tell_to 'return artist of current track'
  end

  def album
    tell_to 'return album of current track'
  end

  def launched?
    nb = %x(osascript -e 'tell app "System Events" to count (every process whose name is "iTunes")' 2>/dev/null).rstrip
    nb.match(/^\d+/) and nb.to_i > 0 ? true : false
  end

  def name
    "iTunes Mac"
  end

  private
    def tell_to(command)
      %x(osascript -e 'tell app "iTunes" to #{command}').rstrip
    end
end
{'fraction_non_alphanumeric': 0.07956318252730109, 'fraction_numerical': 0.005200208008320333, 'mean_word_length': 2.623352165725047, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '3293120', 'n_tokens_mistral': 698, 'n_tokens_neox': 661, 'n_words': 209}