Skip to content
Browse files

Support importing a list of playlists.

  • Loading branch information...
1 parent a31f17d commit 88f9d94b8b5918da80f73c2e7dfe989f9304c95f @loe committed Sep 2, 2011
Showing with 12 additions and 9 deletions.
  1. +12 −9 itunes-playlist.py
View
21 itunes-playlist.py
@@ -1,25 +1,28 @@
#!/usr/bin/env python
-PLAYLIST_NAME="My Top Rated"
+PLAYLIST_NAMES=["My Top Rated"] # Supports a list
PLAYLIST_DESCRIPTION="Imported from iTunes"
import sys, logging
from playlistcreator import PlaylistCreator
+from ScriptingBridge import *
+
pc = PlaylistCreator()
if not pc.authenticated:
print 'You need to authenticate by running ./authenticate.py first'
sys.exit(0)
logging.basicConfig(level=logging.WARNING)
-
-from ScriptingBridge import *
-itunes = SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes")
-playlist = itunes.sources()[0].playlists().objectWithName_(PLAYLIST_NAME)
-itunes_tracks = playlist.tracks()
-rdio_tracks = []
-for track in itunes_tracks:
+for playlist_name in PLAYLIST_NAMES:
+ itunes = SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes")
+ playlist = itunes.sources()[0].playlists().objectWithName_(playlist_name)
+ itunes_tracks = playlist.tracks()
+ rdio_tracks = []
+ for track in itunes_tracks:
#logging.info("%s - %s" % (track.artist().encode("ascii", "replace"), track.name().encode("ascii", "replace")))
rdio_tracks.append((track.artist(),track.name()))
-pc.make_playlist(PLAYLIST_NAME, PLAYLIST_DESCRIPTION, rdio_tracks)
+ if rdio_tracks:
+ pc.make_playlist(playlist_name, PLAYLIST_DESCRIPTION, rdio_tracks)
+

0 comments on commit 88f9d94

Please sign in to comment.
Something went wrong with that request. Please try again.