I switched from pianobar to Pithos as pianobar didn’t work as well with conky as I would have liked. The script below lets me get information from Pithos that I can use in pianobar.
#!/usr/bin/php
< ?php
$song=`dbus-send --print-reply --dest=net.kevinmehall.Pithos /net/kevinmehall/Pithos net.kevinmehall.Pithos.GetCurrentSong`;
$matches = array();
switch($argv[1]) {
case 'album':
$pattern = '~"album".*?"(.*?)".*~s';
break;
case 'title':
$pattern = '~"title".*?"(.*?)".*~s';
break;
case 'artist':
$pattern = '~"artist".*?"(.*?)".*~s';
break;
default:
exit;
}
preg_match($pattern, $song, $matches);
if($matches) {
echo $matches[1];
}