X-Git-Url: http://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=mp3tohtml.py;h=9cdfab5b57c7e36018b66ac9db77986c134cb4a3;hb=c9c45fcea15ceb49e545352a9e8d7d7e12fda3f4;hp=d2e452900a5716295ed089fa30e129dba268ea59;hpb=29f33cb3d47103711ef77842932663ee040260b7;p=radio.git diff --git a/mp3tohtml.py b/mp3tohtml.py index d2e4529..9cdfab5 100755 --- a/mp3tohtml.py +++ b/mp3tohtml.py @@ -1,17 +1,29 @@ #!/usr/bin/python +# Generate an HTML page containing information about MP3s in a +# directory. +# +# Usage: mp3tohtml.py +# +# Last version of this tool can be get from the GIT repository: +# http://git.wpitchoune.net/radio.git +# +# (c) 2015 Jean-Philippe Orsini + import glob import sys import eyeD3 +import os.path if len(sys.argv) != 2: exit(1) -files = glob.glob(sys.argv[1] + "/**/*mp3") +header_path = os.path.dirname(sys.argv[0]) + "/header.tpl" +header = open(header_path, "r") +for line in header: + sys.stdout.write(line) -print "List of songs" -print "

List of songs

" -print "" +files = glob.glob(sys.argv[1] + "/**/*mp3") for f in files: tag = eyeD3.Tag() @@ -20,13 +32,13 @@ for f in files: print "\t" - try: - artist = tag.getArtist().decode('utf-8') - print "\t\t" + try: + artist = tag.getArtist() + print "\t\t" except UnicodeEncodeError: print "\t\t" - try: + try: print "\t\t" except UnicodeEncodeError: print "\t\t" @@ -45,5 +57,9 @@ for f in files: print "\t" print "
" + artist + "" + artist + "" + tag.getAlbum() + "
" - +print "" print ""