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):]
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
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))