fixed correctly the way to retrieve all mp3s
authorJean-Philippe Orsini <jeanfi@gmail.com>
Wed, 27 Jan 2016 00:44:18 +0000 (01:44 +0100)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Wed, 27 Jan 2016 00:44:18 +0000 (01:44 +0100)
mp3tohtml.py

index 9aa51ac..a683c88 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python2
 
 # Generate an HTML page containing information about MP3s in a
 # directory.
@@ -12,7 +12,9 @@
 
 import argparse;
 import eyeD3
+import fnmatch
 import glob
+import os
 import os.path
 import re
 import sys
@@ -46,14 +48,17 @@ def copy_header(path):
     for line in header:
         sys.stdout.write(line)
 
-parser = argparse.ArgumentParser(description='Generate an HTLM containing information about the MP3 files.')
+parser = argparse.ArgumentParser(description='Generate an HTML containing information about the MP3 files.')
 parser.add_argument('dir', help='The directory containing the MP3 files')
 
 args = parser.parse_args()
 
 copy_header(sys.argv[0])
 
-files = glob.iglob(args.dir + "/**/*mp3")
+files = []
+for root, dirnames, filenames in os.walk(args.dir):
+    for filename in fnmatch.filter(filenames, '*.mp3'):
+        files.append(os.path.join(root, filename))
 
 for f in files:
     tag = eyeD3.Tag()