X-Git-Url: http://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=mp3tohtml.py;h=9cdfab5b57c7e36018b66ac9db77986c134cb4a3;hb=c9c45fcea15ceb49e545352a9e8d7d7e12fda3f4;hp=c4432f0d8e5e34b5863ba8f08369a95a1371c04e;hpb=9d21881db0a783f008952b5372e34b0fce08f005;p=radio.git diff --git a/mp3tohtml.py b/mp3tohtml.py index c4432f0..9cdfab5 100755 --- a/mp3tohtml.py +++ b/mp3tohtml.py @@ -1,30 +1,30 @@ #!/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") - -print "" -print "" -print "List of songs" - -print " " -print "" -print " " -print "" -print "" +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

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