Tim’s
Bandwagon

Kung-Tunes

Kung-Tunes:

Kung-Tunes is an AppleScript Studio created OSX donation-ware utility to retrieve the currently played iTunes track and upload it to a webserver.

The latest version now supports recently played tracks. This is how I configured it to upload the tracklist as data to be parsed on the server.

Paste this into the Current Track Format and Recent Tracks Format fields.

<?php
$tracklist['^d']['title'] = '^t';
$tracklist['^d']['artist'] = '#p^p#p';
$tracklist['^d']['composer'] = '#w^w#w';
$tracklist['^d']['album'] = '#a^a#a';
$tracklist['^d']['year'] = '#y^y#y';
$tracklist['^d']['time'] = '#l^l#l';
$tracklist['^d']['genre'] = '#g^g#g';
$tracklist['^d']['stream_url'] = '#u^u#u';
$tracklist['^d']['file'] = '#f^f#f';
$tracklist['^d']['rating'] = '#r^r#r';
$tracklist['^d']['count'] = '#c^c#c';
?>

Set it to upload the the resultant file as php (kungtunes.php) and use something like this to get the data back out again:

<?php
include ('./kungtunes.php');
print '<pre>';
foreach ($tracklist as $date=>$track_data) {
    extract ($track_data);
    print "$date: $title - $artist - $album\n";
}
print '</pre>';
?>

You can get the most recently played track with this:

<?php
include ('./kungtunes.php');
$date_keys = array_keys ($tracklist);
$lastplayed = $date_keys[0];
$track_data = $tracklist[$lastplayed];
extract ($track_data);
print "$lastplayed: $title - $artist - $album\n";
?>

I’ve got mine here: Tim’s most recently listened to tunes, and the most recently played track listed on this page.

13 Comments

  1. Hi, I’m trying out your script above and am not able to get it to work. I’m getting “Parse error: parse error, unexpected ‘”‘ ” when i try to retrieve the track list, and another set of errors when receiving the recently played track. Thanks for any help you can provide. And thanks for the script!

  2. Not sure what to suggest, I should mention that I’ve only tested this in php 4.x, and not all versions of Kung-Tunes. Make sure that ‘encode html entities’ in the formats preference window is checked. I think this is a new option since I posted this article, only fill out the ‘currently playing’ and ‘recently playing’ fields, leave the rest blank. Good luck.

  3. hmm.. I got the same error as Peter. Weiirrd. Cool script , though, I’ll play with it a bit for sure. :-)

  4. Synergy + KungTunes

    If you see on the left hand column, you’d see the tune I’m listening to at the moment. Now I’ve…

  5. Another person had a similar problem (http://www.dgjones.co.uk/archives/000022.html) apparently due to bad whitespace characters (presumably from cutting and pasting from this page). I’ve reformatted the code in the entry above to preformatted block, in the first revision of this entry the code was indented using &nbsp; entities, which might not have been copying into your php scripts correctly. Maybe.

  6. I can’t seem to get this working. Kung-Tunes spits out the PHP just fine to my file (itunes.php), but when I access it using the script (the file path is http://rhdev.homeip.net/~rhale1/itunes/itunes.php), I get a Warning: Invalid argument supplied for foreach() in/Users/rhale1/Sites/index.php on line85 ?> for the single track and Warning: array_keys(): The first argument should be an array in /Users/rhale1/Sites/itunes/recent.php on line 7 Warning: extract(): First argument should be an array in /Users/rhale1/Sites/itunes/recent.php on line 10 : - - when calling the entire recent track list. I’m using 10.3 and PHP 4.3.x with the latest Kung-Tunes.

  7. Ryan, your page (http://rhdev.homeip.net/~rhale1/itunes/itunes.php) looks okay now - did you modify the script or was it another problem?

  8. $tracklist[’^d’][’title’] = ‘^t’;

    if the title contains a ‘, the string will escape and you’ll end up with that error.

  9. Re: #8 (tom)

    Tom. You’re right, although when you have “encode entities” turned on in Kung-Tunes (see comment #2), the apostrophe character is encoded as &#39;

  10. What I’m listening to

    Kung-Tunes is an OS X program that makes it possible to generate a list of your most-recently-heard iTunes tracks, and post them automatically on a web page. So, with some script help from Tim’s Bandwagon, I’ve got the thing up and running on thi…

  11. I’m trying to set up the faceless script for this and I am having a problem figuring out where to put the currecnt song PHP code into the script? Any one know?

    Thanks.

  12. Synergy + KungTunes

    update added the last song heard should I stop listening to iTunes…at least it won’t be so blank like before. If you see on the left hand column, you’d see the tune I’m listening to at the moment. Now I’ve…

  13. I think I’m just stupid but I can’t seem to get the stupid thing to work. Can anybody help me out in any way? Thanks.

Leave a Comment

Your personal information

Your comment