class Library(NSObject):
def init(self):
- self.initWithFilename_("~/Music/iTunes/iTunes Music Library.xml")
+ return self.initWithFilename_("~/Music/iTunes/iTunes Music Library.xml")
def initWithFilename_(self, filename):
filename = os.path.expanduser(filename)
self.playlists = []
for pl_playlist in plist["Playlists"]:
self.playlists.append(self.make_playlist(pl_playlist, pl_tracks))
+ return self
def loc2name(self, location):
return urllib.splithost(urllib.splittype(urllib.unquote(location))[1])[1]
return False
def get_playlist(self, name):
- playlist = [p for p in self.playlists if p.name == name]
+ playlist = [p for p in self.playlists if p.name == name][0]
return playlist.tracks
def list_playlists(self):
sys.exit(1)
logging.info("Loading library")
- library = itunes.Library.alloc().initWithFilename_(opts.itunes_library)
+ if opts.itunes_library:
+ library = itunes.Library.alloc().initWithFilename_(opts.itunes_library)
+ else:
+ library = itunes.Library.alloc().init()
for playlist in opts.playlists:
if not library.has_playlist(playlist):