NAME

Mac::iTunes::Library - Perl extension for representing an iTunes library

SYNOPSIS

use Mac::iTunes::Library;

my $library = Mac::iTunes::Library->new();
my $item = Mac::iTunes::Library::Item->new(
      'Track ID' => 1,
      'Name' => 'The Fooiest Song',
      'Artist' => 'The Bar Band',
      );
$library->add($item);
print "This library has only " . $library->num() . "item.\n";

DESCRIPTION

A data structure for representing an iTunes library.

The library keeps track of the number of tracks by each artist (a hash of Artist => num_tracks) and the number of songs in each genre (Genre => num_tracks). Additionally, the total playcounts for each artist (Artist => playcount_of_all_songs) and genre (Genre => playcount_of_all_songs) are tallied. Finally, all of the items in the library are available, sorted by artist.

EXPORT

None by default.

METHODS

new()

Creates a new Mac::iTunes::Library object that can store Mac::iTunes::Library::Item objects.

version()

Get/set the plist version number.

majorVersion()

Get/set the Major Version number

minorVersion()

Get/set the Minor Version number

applicationVersion()

Get/set the Application Version number

features()

Get/set the Features attribute

showContentRatings()

Get/set the Show Content Ratings attribute

musicFolder()

Get/set the Music Folder attribute

libraryPersistentID()

Get/set the Library Persistent ID

num()

Get the number of tracks in the library

size()

Get the total size of the library

time()

Get the total time of the library

artist()

Get the hash of the number of tracks for each artist.

partist()

Get the hash of the number of plays (playcount) for each artist.

albumArtist()

Get the hash of the number of tracks for each albumArtist.

palbumArtist()

Get the hash of the number of plays (playcount) for each albumArtist.

genre()

Get the hash of the number of tracks in each genre.

pgenre()

Get the hash of the number of plays (playcount) for each genre.

type()

Get the hash of item types in the library

items()

Get the hash of Items (Artist->Name->[item, item]) contained in the library; artist names are the top level keys; accessing one gives you a hash-ref with keys of song names and array-refs as values. Those array-refs contain Mac::iTunes::Library::Item objects.

Example traversal:
# Assuming a previously created library
%items = $library->items();
foreach my $artist (keys %items) {
    my $artistSongs = $items{$artist};

    foreach my $songName (keys %$artistSongs) {
        my $artistSongItems = $artistSongs->{$songName};

        foreach my $item (@$artistSongItems) {
            # Do something here to every item in the library
            print $song->name() . "\n";
        }
    }
}

add( Mac::iTunes::Library::Item )

Add an item to the library

SEE ALSO

Mac::iTunes::Library::XML, Mac::iTunes::Library::Item, Mac::iTunes::Library::Playlist

AUTHOR

Drew Stephens <drew@dinomite.net>, http://dinomite.net

CONTRIBUTORS

Mark Grimes <mgrimes@cpan.org>, http://www.peculiarities.com Scott Lawrence (http://linkedin.com/in/scottdlawrence) Garrett Scott <garrett@gothik.org>, (http://www.gothik.org)

SOURCE REPOSITORY

http://mac-itunes.googlecode.com

SVN INFO

$Revision: 78 $ $Date: 2009-12-30 10:33:01 -0700 (Wed, 30 Dec 2009) $ $Author: drewgstephens $

COPYRIGHT AND LICENSE

Copyright (C) 2007-2008 by Drew Stephens

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.