Adoptable Modules
and 1 contributors


Mac::iTunes - interact with and control iTunes


        use Mac::iTunes;

        # if you have Mac::iTunes::AppleScript
        my $controller = Mac::iTunes->controller();

        my $library = Mac::iTunes->new( $library_path );


**This module is unmaintained**



Creates a new, empty Mac::iTunes object. If you want to read a current library, use read().

Returns false on failure.


Creates a new Mac::iTunes controller object. See Mac::iTunes::AppleScript for methods. This method is not available on non-Mac systems.

preferences( [ FILENAME ] )

Read the iTunes preferences from the given FILENAME, or the file ~/Library/Preferences/ .


In list context, returns a list of the titles of the playlists. In scalar context, returns the number of playlists.

get_playlist( PLAYLIST )

Takes a playlist title argument.

Extracts a Mac::Playlist object from the music library. Returns undef if the playlist does not exist.

add_playlist( PLAYLIST_OBJECT )

Takes a Mac::iTunes::Playlist object as its only argument.

Adds the playlist to the music library and returns a true value. If it cannot add the playlist object, perhaps because it is not a playlist object, it returns undef.

delete_playlist( PLAYLIST | OBJECT )

Takes a playlist title or Mac::iTunes::Playlist object as an argument.

Removes the playlist from the music library.

playlist_exists( PLAYLIST | OBJECT )

Takes a playlist title or Mac::iTunes::Playlist object as an argument.

Returns true if the playlist exists in the music library, and false otherwise.

The playlist exists if the music library has a playlist with the same title, or if the object matches another object in the music library. See Mac::iTunes::Playlist to see how one playlist object may match another.

NOTE: at the moment, if you use an object argument, the function extracts the title of the playlist and sees if that title is in the library. this is just a placeholder until i come up with something better.

read( FILENAME )

*** NOTE: This does not work for iTunes 4.6 and later, which has a different file format. Can anyone help me figure out what that format is? ***

Reads the named iTunes Music Library file and uses it to form the music library object, replacing any other data already in the object.



Merges the current music library with the one in the named file or Mac::iTunes object. Does not affect the object argument.


UNIMPLEMENTED! Just dumps it with Data::Dumper.

Returns the music library as a string suitable for an iTunes Music Object file.


* everything - the list of things already done is much shorter.

* speed everything up 100 times with Mac::Glue when it works on Mac OS X

* Figure out the new file format for the binary library file


* plenty


This source is in GitHub:


brian d foy, <>


Copyright (c) 2002-2008 brian d foy. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.