Skip to content

Instantly share code, notes, and snippets.

@dblume
Created November 2, 2020 19:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dblume/249fbc90ce5ef0772b05b5f387f828a4 to your computer and use it in GitHub Desktop.
Save dblume/249fbc90ce5ef0772b05b5f387f828a4 to your computer and use it in GitHub Desktop.
Make a list of playlists from an iTunes XML file
#!/usr/bin/env python3
import libpytunes # https://github.com/liamks/libpytunes
if __name__ == '__main__':
l = libpytunes.Library('iTunes Music Library.xml')
with open('playlists.txt', 'w', encoding='utf-8') as f:
for p in l.getPlaylistNames():
if p not in ('Downloaded', 'Audiobooks', 'Voice Memos', 'Not One Star Rating'):
f.write(p)
f.write('===\n\n')
for s in l.getPlaylist(p).tracks:
f.write(f'[{s.album}: {s.track_number}] {s.artist} - {s.name}\n')
f.write('\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment