‘pytunes.py‘ provides a generalized interface for controlling media players, such as Apple’s iTunes. This implementation only works with iTunes on Windows but we expect to have a Macintosh implementation later this week and hope to demonstrate a controller for Windows Media Player also (if anyone can help me with the COM interfaces here, I’d be very grateful). This version concentrates on manipulating the playlists, adding songs and so forth rather than playing music, controlling the volume, etc. as this is my immediate need for the Podcasting version of BlogMatrix Jäger.
import pytunes itunes = pytunes.iTunesWindows() # list everything in the Playlist 'Recently Played' playlist = itunes.GetPlaylistByName('Recently Played') for track in playlist.IterAllTracks(): pprint.pprint({ "album" : track.GetAlbum(), "title" : track.GetTitle(), "composer" : track.GetComposer(), "artist" : track.GetArtist(), }) # list songs with the word 'Love' in the Title for track in library_playlist.SearchTitles("Love"): pprint.pprint({ "album" : track.GetAlbum(), "title" : track.GetTitle(), "composer" : track.GetComposer(), "artist" : track.GetArtist(), })