Use the Library class to parse iTunes XML
masterThe Library class is the primary entry point for interacting with your iTunes data. You must provide the path to your iTunes Library.xml file.
Note: If you do not see an .xml file in ~/Music/iTunes, you must enable sharing in iTunes Preferences | Advanced > "Share iTunes Library XML with other applications."
from libpytunes import Library
# Initialize the library with the path to your XML file
l = Library("/path/to/iTunes Library.xml")
# Access songs via the .songs dictionary (keyed by TrackID)
for id, song in l.songs.items():
if song and song.rating:
if song.rating > 80:
print(song.name, song.rating)
# Access playlists
playlists = l.getPlaylistNames()
for song in l.getPlaylist(playlists[0]).tracks:
print("[{t}] {a} - {n}".format(t=song.track_number, a=song.artist, n=song.name))