Skip to content

Instantly share code, notes, and snippets.

@mdmsua
Created June 14, 2017 14:48
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 mdmsua/e34efeacd4dd1d5eb4be2514804145c4 to your computer and use it in GitHub Desktop.
Save mdmsua/e34efeacd4dd1d5eb4be2514804145c4 to your computer and use it in GitHub Desktop.
if let library = try? ITLibrary(apiVersion: "1") {
print(library.applicationVersion)
for artist in library.allMediaItems
.filter({ $0.mediaKind == ITLibMediaItemMediaKind.kindSong })
.group(by: { $0.artist?.name }){
print(artist.key)
for album in artist.value.group(by: { $0.album.title }) {
print(" \(album.key) (\(album.value.first!.year))")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment