Main Page | Class List | File List | Class Members | File Members

libipod - a library for managing the Apple iPod


Duane Maxwell, Linspire, Inc


libipod is a lightweight library written in C for the management of the Apple iPod. It includes wrappers for C++ and Python, as well as a number of example programs. libipod is the basis for the iPod support in Lsongs, a GPL music manager/player for Linux published by Linspire, Inc. You can find more information about Lsongs at

libipod is licensed under the Lesser GNU Public License (LGPL), which basically means that this the code may be used in either Open or Closed source programs, as long as the source of libipod is made available on request. For more information on the license, please read the the file "COPYING", which is included with the source distribution, or view the text of the LGPL at

This project is hosted by Sourceforge, at
Project files can be downloaded from

We encourage code contributions and assistance from the community on this project. In particular, we are interested in language bindings in order to make iPod support easy for developers to include in their projects.

A simple C++ example

 #include "ipod/ipod_cpp.h"
 #include "ipod/ipod_constants.h"
 #include <iostream>
 using namespace std;
 int main(int argc,char **argv) {
    string *ipod_paths;
    int ipod_count = IPod::Discover(&ipod_paths);
    for (int ipod_index=0;ipod_index<ipod_count;ipod_index++) {
        string path = ipod_paths[ipod_index];
        IPod ipod(path);
        cout << "iPod at " << path << " (" << ipod.TrackCount() << " tracks, " << ipod.PlaylistCount() << " playlists)" << endl;
        for (unsigned long i=0;i<ipod.TrackCount();i++) {
            IPodTrack track = ipod.TrackByIndex(i);
            string title = track.GetText(IPOD_TITLE);
            string artist = track.GetText(IPOD_ARTIST);
            uint32_t trackID = track.GetAttribute(IPOD_TRACK_ID);
            cout << "  Index " << i << " TrackID " << trackID << ": '" << title << "' " << artist << endl;
        for (unsigned long i=0;i<ipod.PlaylistCount();i++) {
            IPodPlaylist playlist = ipod.PlaylistByIndex(i);
            string name = playlist.GetText(IPOD_TITLE);
            cout << endl << "Playlist " << i << ": '" << name << "' (" << playlist.TrackItemCount() << " tracks)" << endl;
            for (unsigned long j=0;j<playlist.TrackItemCount();j++) {
                IPodTrackItem item = playlist.TrackItemByIndex(j);
                uint32_t trackID = item.GetAttribute(IPOD_TRACK_ITEM_TRACK_ID);
                IPodTrack track = ipod.TrackByTrackID(trackID);
                string title = track.GetText(IPOD_TITLE);
                cout << "  Index " << j << " TrackID " << trackID << ": '" << title << "'" << endl;

Python support

libipod also includes fairly high-level bindings for Python. You may view the specific documentation for Python by doing the following:
 user@host:~$ python -c "import ipod; help(ipod)"

A simple Python example

    from ipod import *

    paths = IPod.paths()
    if len(paths):
        ipod = IPod(paths[0])
        total,free = ipod.diskUsage()
        print "iPod at %s (total %dK, free %dK)" % (paths[0],total,free)
        for track in ipod.tracks:
            print "  TrackID %d:  %s - %s/%s (%s)" % (,track.title,track.artist,track.album,track.fileType)
        for playlist in ipod.playlists:
            print "Playlist: %s" %
            for trackItem in playlist.trackItems:
                print "  TrackID %d: %s" % (,ipod.trackForID(
        for preset in ipod.eqPresets:
            print "Preset: %s preamp %d" % (,preset.preamp),
            print [preset.bandA[i] for i in xrange(10)],
            print [preset.bandB[i] for i in xrange(5)]
        print "no iPods found!"

Acknowledgements and Notices

Thanks for Linspire, Inc for sponsoring this project.

"Apple", "iPod", and "iTunes" are registered trademarks of Apple Computer, Inc. "Shuffle" is a trademark of Apple Computer, Inc. "iTunes Music Store" is a service mark of Apple Computer, Inc.

"Linspire" is a trademark of Linspire, Inc.

This project is neither sponsored nor endorsed by Apple Computer, Inc

Generated on Tue Dec 13 14:55:22 2005 for libipod by  doxygen