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