<?php
$state = trim(shell_exec("osascript -e 'tell application \"iTunes\" to player state as string'"));
$artist= shell_exec("osascript -e 'tell application \"iTunes\" to artist of current track as string'");
$track = shell_exec("osascript -e 'tell application \"iTunes\" to name of current track as string'");
$html = file_get_contents('scripts/template.html');
// fill in the gaps
$html = str_replace('[TRACK]', $track, $html);
$html = str_replace('[ARTIST]', $artist, $html);
if($state == 'playing')
$html = str_replace('[PLAY-PAUSE]', 'pause', $html);
else
$html = str_replace('[PLAY-PAUSE]', 'play', $html);
echo $html;
?>