<commit_before>--- === hs.itunes ===
---
--- Controls for iTunes music player

local itunes = {}

local alert = require "hs.alert"
local as = require "hs.applescript"

-- Internal function to pass a command to Applescript.
local function tell(cmd)
  local _cmd = 'tell application "iTunes" to ' .. cmd
  local _ok, result = as.applescript(_cmd)
  return result
end

--- hs.itunes.play() -> nil
--- Function
--- Toggles play/pause of current itunes track
function itunes.play()
  tell('playpause')
  alert.show(' ▶', 0.5)
end

--- hs.itunes.pause() -> nil
--- Function
--- Pauses of current itunes track
function itunes.pause()
  tell('pause')
  alert.show(' ◼', 0.5)
end

--- hs.itunes.next() -> nil
--- Function
--- Skips to the next itunes track
function itunes.next()
  tell('next track')
  alert.show(' ⇥', 0.5)
end

--- hs.itunes.previous() -> nil
--- Function
--- Skips to previous itunes track
function itunes.previous()
  tell('previous track')
  alert.show(' ⇤', 0.5)
end

--- hs.itunes.displayCurrentTrack() -> nil
--- Function
--- Displays information for current track
function itunes.displayCurrentTrack()
  artist = tell('artist of the current track as string')
  album  = tell('album of the current track as string')
  track  = tell('name of the current track as string')
  alert.show(track .."\n".. album .."\n".. artist, 1.75)
end

return itunes
<commit_msg>Add hs.itunes.getCurrentArtist(), hs.itunes.getCurrentAlbum() and hs.itunes.getCurrentTrack(). Also update hs.itunes docstrings to new format<commit_after>--- === hs.itunes ===
---
--- Controls for iTunes music player

local itunes = {}

local alert = require "hs.alert"
local as = require "hs.applescript"

-- Internal function to pass a command to Applescript.
local function tell(cmd)
  local _cmd = 'tell application "iTunes" to ' .. cmd
  local _ok, result = as.applescript(_cmd)
  return result
end

--- hs.itunes.play()
--- Function
--- Toggles play/pause of current iTunes track
---
--- Parameters:
---  * None
---
--- Returns:
---  * None
function itunes.play()
  tell('playpause')
  alert.show(' ▶', 0.5)
end

--- hs.itunes.pause()
--- Function
--- Pauses of current iTunes track
---
--- Parameters:
---  * None
---
--- Returns:
---  * None
function itunes.pause()
  tell('pause')
  alert.show(' ◼', 0.5)
end

--- hs.itunes.next()
--- Function
--- Skips to the next itunes track
---
--- Parameters:
---  * None
---
--- Returns:
---  * None
function itunes.next()
  tell('next track')
  alert.show(' ⇥', 0.5)
end

--- hs.itunes.previous()
--- Function
--- Skips to previous itunes track
---
--- Parameters:
---  * None
---
--- Returns:
---  * None
function itunes.previous()
  tell('previous track')
  alert.show(' ⇤', 0.5)
end

--- hs.itunes.displayCurrentTrack()
--- Function
--- Displays information for current track on screen
---
--- Parameters:
---  * None
---
--- Returns:
---  * None
function itunes.displayCurrentTrack()
  artist = tell('artist of the current track as string')
  album  = tell('album of the current track as string')
  track  = tell('name of the current track as string')
  alert.show(track .."\n".. album .."\n".. artist, 1.75)
end

--- hs.itunes.getCurrentArtist()
--- Function
--- Gets the name of the current Artist
---
--- Parameters:
---  * None
---
--- Returns:
---  * A string containing the Artist of the current track
function itunes.getCurrentArtist()
    return tell('artist of the current track as string')
end

--- hs.itunes.getCurrentAlbum()
--- Function
--- Gets the name of the current Album
---
--- Parameters:
---  * None
---
--- Returns:
---  * A string containing the Album of the current track
function itunes.getCurrentAlbum()
    return tell('album of the current track as string')
end

--- hs.itunes.getCurrentTrack()
--- Function
--- Gets the name of the current track
---
--- Parameters:
---  * None
---
--- Returns:
---  * A string containing the name of the current track
function itunes.getCurrentTrack()
    return tell('name of the current track as string')
end

return itunes

{'fraction_non_alphanumeric': 0.1694451356058721, 'fraction_numerical': 0.005473998507091316, 'mean_word_length': 2.767572633552015, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '4708285', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1273, 'n_words': 422}