-#!/usr/bin/python
+#!/usr/bin/python2
# Generate an HTML page containing information about MP3s in a
# directory.
import argparse;
import eyeD3
+import fnmatch
import glob
+import os
import os.path
import re
import sys
for line in header:
sys.stdout.write(line)
-parser = argparse.ArgumentParser(description='Generate an HTLM containing information about the MP3 files.')
+def copy_footer(path):
+ footer_path = os.path.dirname(path) + "/header.tpl"
+ footer = open(footer_path, "r")
+ for line in footer:
+ sys.stdout.write(line)
+
+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])
+cfg_dir = sys.argv[0]
-files = glob.iglob(args.dir + "/**/*mp3")
+copy_header(cfg_dir)
+
+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()
print("\t</tr>")
+copy_footer(cfg_dir)
+
print("</table>")
print (" <ul>")
print ("<footer>")