iTunes automatically creates a backup copy of its library file in a XML format. Manually creating this file from the File->Library menu is also possible. By doing so, the entire iTunes Library metadata is exported to an XML format where it can be further processed. Common requirements may be to import the library into an Excel spreadsheet as a comma-separated-value (CSV) file, or to insert the metadata into a database using SQL statements.
For me, I was working on a audio/video related project and I needed some sample, yet real-life metadata to work with. So I ended up writing a simple and compressive iTunes parsing library, implemented as a single XSL that performs most of the work. This proved to be especially useful since Apple did not implement the iTunes Library as a 'real' schema, but rather a freeform key/value pair whose definition isn't published anywhere.
The iTunes Stylesheet XSL is freely available under a BSD license. Using it can greatly reduce the amount of effort required to parse and use iTunes Library metadata. The library has been developed and tested against iTunes version 9.
Now on to the code... The following example shows how easy it is to iterate through every title and output the name and artist.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:include href="iTunes.xsl">
<xsl:template match="/">
<xsl:for-each select="plist/dict/dict/dict">
<xsl:call-template name="name">,
<xsl:call-template name="artist">
</xsl:for-each>
</xsl:call-template>
Now suppose the requirement was to insert the library into a SQL database; no problem. The iTunes Stylesheet XSL has a built-in template for escaping when the output is SQL, specifically, it escapes singles quotes.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:include href="iTunes.xsl">
<xsl:template match="/">
<xsl:for-each select="plist/dict/dict/dict">
<xsl:call-template name="sql_escape">
<xsl:with-param name="arg1">
<xsl:call-template name="name">
</xsl:call-template>
</xsl:with-param>,
<xsl:call-template name="sql_escape">
<xsl:with-param name="arg1">
<xsl:call-template name="artist">
</xsl:call-template>
</xsl:with-param>
</xsl:for-each>
</xsl:call-template>
Download iTunes Stylesheet XSL
iTunes Stylesheet XSL contains templates to parse the following:
- Track ID
- Name
- Artist
- Composer
- Album Artist
- Album
- Genre
- Kind
- Size
- Total Time
- Disc Number
- Disc Count
- Track Number
- Track Count
- Year
- Date Modified
- Date Added
- Bit Rate
- Sample Rate
- Comments
- Play Count
- Play Date
- Play Date UTC
- Release Date
- Artwork Count
- Rating
- Rating Computed
- Album Rating
- Series
- Season
- Episode
- Episode Order
- Content Rating
- Persistent ID
- Track Type
- Purchased
- Podcast
- Unplayed
- Has Video
- HD
- Movie
- TV Show
- Music Video
- Video Width
- Video Height
- Location
- File Folder Count
- Library Folder Count












In the era of YouTube and sub $1000 pro-sumer cameras, the need for video encoding tools is ever increasing. By in-large, the demand for such tools is no longer a job for the professional. Today, literally hundreds of encoding tools exist. Googling "Video Encoding Tools" yields just under 45,000 results. So how do you know which tool to use?
For the last several years, Blu-ray and HD-DVD have been duking it out. Blu-ray was initially far superior to HD-DVD because of the use of the blue laser whereas HD-DVD initially used red. At the present time however, there isn't much difference between the two. They both use blue lasers, both have high capacity (although Blu-ray Disk still holds more), both support 1080p and interactive features. So what's the difference and why should you care?
