Skip to content

Parse an iTunes XML file (the full library or partial export) for its info, tracks and playlists. Original work by Robert A. Wallis, with PHP5 support by Peter Minarik.

License

Notifications You must be signed in to change notification settings

shuckster/iTunes-XML-parser-for-PHP

Repository files navigation

iTunes XML parser for PHP

A class to extract info, tracks and playlists from an iTunes XML file.

Original code copyright (c) 2003 by Robert A. Wallis. Dicked around with in 2005 by Peter Minarik, and in 2013-2021 by Conan Theobald.

LGPL2.1 licensed: See LICENSE

About

A simple PHP class that will read an iTunes XML file and convert the info, tracks and playlists contained within into an array of objects.

Tracks can be matched to playlist-items by running the #processPlaylists() method after opening your XML file.

Supports sorting fields by string, number, and date.

Instructions

See example.php for a basic implementation.

require_once 'iTunesXMLparser.class.php';

$xml_path = 'iTunes playlist export.xml';

$itunes = new iTunesXMLParser();
$itunes->sort_field = 'Track ID';
$itunes->sort_direction = 'ascending';
$itunes->open( $xml_path );

/*
  "$itunes->data" is now available. print_r to see what's inside:
    print_r( $itunes->data );
*/

For conversion to JSON, I recommend using the jsbeautifier.org PHP port.

EDIT - No need for that now. :)

2021 update

Before releasing 1.6 I discovered a fork by @dajoho that has a composer.json:

This version had also already fixed the sort() bug 2 years ago! :)

Contributors

Credits

Based on work by:

About

Parse an iTunes XML file (the full library or partial export) for its info, tracks and playlists. Original work by Robert A. Wallis, with PHP5 support by Peter Minarik.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages