]> code.delx.au - notipod/blobdiff - libsyncitunes.py
It works! :)
[notipod] / libsyncitunes.py
index e9ed9cd1bf3f5504c55145a249d930b5cf06250a..3bccfec30a9bbe1e4a00d279028ca6a9bddbb02e 100644 (file)
@@ -120,10 +120,14 @@ class ITunesLibrary(NSObject):
 def export_m3u(dry_run, dest, path_prefix, playlist_name, files):
        if dry_run:
                return
-       f = open(os.path.join(dest, playlist_name) + ".m3u", "w")
+       playlist_file = os.path.join(dest, playlist_name) + ".m3u"
+       logging.info("Writing: " + playlist_file)
+       f = open(playlist_file, "w")
        for filename in files:
-               filename = filename.replace("/", "\\").encode("utf-8")
-               f.write("%s\\%s\\%s\n" % (path_prefix, filename))
+               if path_prefix.find("\\") > 0:
+                       filename = filename.replace("/", "\\")
+               filename = filename.encode("utf-8")
+               f.write("%s%s\n" % (path_prefix, filename))
        f.close()
 
 def strip_prefix(s, prefix):
@@ -173,7 +177,7 @@ def sync(dry_run, source, dest, files):
                                else:
                                        logging.debug("update: " + filename)
 
-                       elif not filename.startswith("Playlists/"):
+                       elif not filename.endswith(".m3u"):
                                logging.debug("delete: " + filename)
                                if not dry_run:
                                        os.unlink(join(dest, filename))