Accessing iTunes XML metadata with Python

Tutorial – iTunes XML

Article from Issue 264/2022

Read and manipulate data from your iTunes XML in order to share music metadata between applications and across devices.

The Extensible Markup Language (XML)[1] is a widely used markup language and text file format for storing and exchanging arbitrary data. A wide variety of applications, including the Apple iTunes application, use the XML format for exchanging or storing library data. In this article, I will show you how to use Python to read and manipulate data from an iTunes [2] XML library file.

iTunes Library File

iTunes divides its content into two separate categories: media and metadata. Media (music and video) are saved in separate files from metadata. Throughout the rest of this article, I will focus on music information – artist, song title, album title, track number, genre, release year – and refer to it as metadata. The iTunes metadata files have either a .itl or .xml extension (Figure 1).

Why Choose XML?

If you are a music lover like me, there may be times when you want to exchange music metadata between a variety of applications on a variety of digital devices. In my case, I have imported iTunes metadata into database applications to run SQL queries. Some applications use proprietary formats to get optimum performance and efficiency but limit access with proprietary products. The iTunes .itl format is an example. On the other hand, there are open formats that place more of an emphasis on wide availability and ease of development. XML is in the open format category.


Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Musical Talent: Songbird 1.2 has Landed

    The new version automatically organizes music libraries and is fully integrative with iTunes.

  • Managing Music with Picard

    Getting that iTunes experience requires more than just Amarok or Rhythmbox. It also requires planning – especially if you went digital before the Linux desktop had audio players.

  • Firefly Audio Streaming

    The Firefly Media Server makes streaming music and Internet radio onto your home network for iTunes or Banshee clients as easy as pie.

  • Banshee

    In Irish mythology, the banshee’s mourning call is heard when a member of the family is about to die. The Banshee tool on Linux makes noise too, but for a far happier purpose. This banshee helps you organize your musical collection.

  • LibreOffice Music Database

    LibreOffice Calc and Base are all you need to create a simple database for organizing the songs in your music collection.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.