X-Git-Url: https://code.delx.au/notipod/blobdiff_plain/fd45d2bc20ac9ed64deba0ae046cdc96a4fa9bd7..cbf749aac869dcb3bec9077a1d1051a6a461f33c:/libsyncitunes.py diff --git a/libsyncitunes.py b/libsyncitunes.py index c8d330c..4122891 100644 --- a/libsyncitunes.py +++ b/libsyncitunes.py @@ -133,19 +133,6 @@ def encode_filename(filename): encoded_names[orig_filename] = filename return filename -def export_m3u(dry_run, dest, path_prefix, playlist_name, files): - if dry_run: - return - playlist_file = os.path.join(dest, playlist_name) + ".m3u" - logging.info("Writing: " + playlist_file) - f = open(playlist_file, "w") - for filename in files: - if path_prefix.find("\\") > 0: - filename = filename.replace("/", "\\") - filename = encode_filename(filename) - f.write("%s%s\n" % (path_prefix, filename)) - f.close() - def strip_prefix(s, prefix): assert s.startswith(prefix) s = s[len(prefix):] @@ -166,6 +153,20 @@ def mkdirhier(path): except OSError: pass +def export_m3u(dry_run, dest, path_prefix, playlist_name, files): + if dry_run: + return + playlist_file = os.path.join(dest, "-Playlists-", playlist_name) + ".m3u" + mkdirhier(os.path.dirname(playlist_file)) + logging.info("Writing: " + playlist_file) + f = open(playlist_file, "w") + for filename in files: + if path_prefix.find("\\") > 0: + filename = filename.replace("/", "\\") + filename = encode_filename(filename) + f.write("%s%s\n" % (path_prefix, filename)) + f.close() + def sync(dry_run, source, dest, files): join = os.path.join @@ -198,7 +199,7 @@ def sync(dry_run, source, dest, files): else: yield "Update: " + filename - elif not filename.endswith(".m3u"): + elif not filename.startswith("-Playlists-"): yield "Delete: " + filename if not dry_run: os.unlink(join(dest, filename))