diff --git a/gen.py b/gen.py
index bff2340..5edf47e 100644
--- a/gen.py
+++ b/gen.py
@@ -69,7 +69,13 @@ def emit_audio(file, data_dir):
#out += "" + a["length"] + "\n"
out += "\n"
out += "\n"
out += "\n"
@@ -141,7 +147,9 @@ def index_content(dir_name, data_dir, index_txt, desc_txt, template):
else:
files += [os.path.basename(a) for a in glob.glob(f)];
-
+ # sort files?
+ files.sort()
+
for j in files:
x, ext = os.path.splitext(j);
ext = ext.lower()
diff --git a/index_template.html b/index_template.html
index 73a02e6..0238ca7 100644
--- a/index_template.html
+++ b/index_template.html
@@ -12,7 +12,7 @@
-

+
Gauthiier - (Selected) Index
d[at]gauthiier.info
diff --git a/wavconv.py b/wavconv.py
new file mode 100644
index 0000000..cec0345
--- /dev/null
+++ b/wavconv.py
@@ -0,0 +1,61 @@
+import argparse, sys, os, glob, subprocess
+
+supported = ['ogg', 'mp3']
+
+def sanity_check_system():
+ r = subprocess.call("ffmpeg -version", shell=True) == 0
+ if not r:
+ sys.exit("ffmpeg not installed. Aborting...")
+
+def convert(i, o, f):
+ global supported
+ if f not in supported:
+ print("warning: format " + f + "is not supported")
+ return
+
+ if f == 'mp3':
+ codec = 'libmp3lame'
+ elif f == 'ogg':
+ codec = 'libvorbis'
+
+ subprocess.call(['ffmpeg', '-i', i, '-acodec', codec, o])
+
+
+if __name__ == '__main__':
+
+ p = argparse.ArgumentParser(description='Converts .wav files to other formats (using ffmpeg)');
+ p.add_argument('-i', '--input', help='input directory');
+ p.add_argument('-f', '--format', help='output formats (ogg and/or mp3)', nargs="+");
+
+ sanity_check_system()
+
+ args = p.parse_args()
+
+ if not args.format:
+ sys.exit("Nor formats specified. Aborting.")
+
+ formats = []
+ for f in args.format:
+ if f not in supported:
+ print("warning: format " + f + "is not supported")
+ else:
+ formats.append(f)
+
+ if not formats:
+ sys.exit("None of the specified formats are supported. Aborting.")
+
+ input_dir = "."
+ if args.input:
+ input_dir = args.input
+
+ wav_files = glob.glob(os.path.join(input_dir, "*.wav"))
+ for w in wav_files:
+ for f in formats:
+ fn = os.path.join(input_dir, os.path.basename(w).replace('.wav', '.' + f))
+ convert(w, fn, f)
+
+
+
+
+
+