]> code.delx.au - notipod/commitdiff
Fixes
authorJames Bunton <jamesbunton@fastmail.fm>
Sun, 2 Jan 2011 03:58:39 +0000 (14:58 +1100)
committerJames Bunton <jamesbunton@fastmail.fm>
Sun, 2 Jan 2011 03:58:39 +0000 (14:58 +1100)
.hgignore
itunes.py
sync.py

index 12c0927c463a7ce5ac7a56e68fb26381109b9c0f..bb133bdd5c9fca11ebd3fc013facf8c80f56d5ee 100644 (file)
--- a/.hgignore
+++ b/.hgignore
@@ -5,3 +5,4 @@ build
 *.mode1v3
 *.pbxuser
 *.pch
+tmp
index 8d2848b66fbd6faadfc5a66002d5aeef3f0c14e2..ea3754118d03b1f8ff93694d087d98cb86e98f08 100644 (file)
--- a/itunes.py
+++ b/itunes.py
@@ -32,7 +32,7 @@ class Playlist(object):
 
 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)
@@ -42,6 +42,7 @@ class Library(NSObject):
                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]
@@ -65,7 +66,7 @@ class Library(NSObject):
                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):
diff --git a/sync.py b/sync.py
index 2ec3d296c269c3adbd3cf84e9c2d1b3653f175d4..9375c913a922b354834dd77367a26046b4e16a97 100755 (executable)
--- a/sync.py
+++ b/sync.py
@@ -59,7 +59,10 @@ def main():
                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):