first real version
[radio.git] / mp3tohtml.py
diff --git a/mp3tohtml.py b/mp3tohtml.py
new file mode 100755 (executable)
index 0000000..d2e4529
--- /dev/null
@@ -0,0 +1,49 @@
+#!/usr/bin/python
+
+import glob
+import sys
+import eyeD3
+
+if len(sys.argv) != 2:
+    exit(1)
+
+files = glob.glob(sys.argv[1] + "/**/*mp3")
+
+print "<html><head><title>List of songs</title></head>"
+print "<body><h1>List of songs</h1>"
+print "<table>"
+
+for f in files:
+    tag = eyeD3.Tag()
+
+    tag.link(f)
+
+    print "\t<tr>"
+
+    try: 
+        artist = tag.getArtist().decode('utf-8')
+        print "\t\t<td>" + artist + "</td>"       
+    except UnicodeEncodeError:
+        print "\t\t<td></td>"
+
+    try:        
+        print "\t\t<td>" + tag.getAlbum() + "</td>"
+    except UnicodeEncodeError:
+        print "\t\t<td></td>"
+
+    try:
+        print "\t\t<td>" + tag.getTitle() + "</td>"
+    except UnicodeEncodeError:
+        print "\t\t<td></td>"
+
+    print "\t\t<td>"
+    comments = tag.getComments()
+    for c in comments:
+        print comments[0].comment
+    print "\t\t</td>"
+
+    print "\t</tr>"
+
+print "</table>"
+    
+print "</body></html>"