X-Git-Url: https://git.wpitchoune.net/gitweb/?p=mp3tohtml.git;a=blobdiff_plain;f=mp3tohtml%2Fmp3tohtml.py;h=4a9d8a353cce919767bcee8e66c8bdd2a8692e20;hp=db32bdc832f20546ddfa613bb2d819c6071cfd62;hb=09378a563a2e0f94e94fd83c0089edc59b33b77c;hpb=0367f55bb55d93d2e3f0032c2b8c01472d9dd2d6 diff --git a/mp3tohtml/mp3tohtml.py b/mp3tohtml/mp3tohtml.py index db32bdc..4a9d8a3 100755 --- a/mp3tohtml/mp3tohtml.py +++ b/mp3tohtml/mp3tohtml.py @@ -1,16 +1,23 @@ #!/usr/bin/python2 -# Generate an HTML page containing information about MP3s in a -# directory. +# usage: mp3tohtml.py [-h] [--config CONFIG] dir # -# Usage: mp3tohtml.py +# Generate an HTML containing information about the MP3 files. +# +# positional arguments: +# dir The directory containing the MP3 files +# +# optional arguments: +# -h, --help show this help message and exit +# --config CONFIG The directory containing the configuration # # Last version of this tool can be get from the GIT repository: -# http://git.wpitchoune.net/radio.git +# http://wpitchoune.net/mp3tohtml # +# Released under the terms of the GPLv2 license. # (c) 2016 Jean-Philippe Orsini -import argparse; +import argparse import eyeD3 import fnmatch import glob @@ -43,15 +50,30 @@ def fma_copyright_to_html(path, copyright): def copy_header(path): header_path = path + "/header.tpl" - header = open(header_path, "r") - for line in header: - sys.stdout.write(line) + try: + header = open(header_path, "r") + for line in header: + sys.stdout.write(line) + except IOError as err: + sys.stderr.write("Failed to read header file " + + header_path + + ": " + err.strerror + "\n") + sys.exit(1) + header.close() def copy_footer(path): footer_path = path + "/footer.tpl" - footer = open(footer_path, "r") - for line in footer: - sys.stdout.write(line) + try: + footer = open(footer_path, "r") + for line in footer: + sys.stdout.write(line) + except IOError as err: + sys.stderr.write("Failed to read footer file " + + footer_path + + ": " + err.strerror + "\n") + sys.exit(1) + footer.close() + parser = argparse.ArgumentParser(description='Generate an HTML containing information about the MP3 files.') parser.add_argument('dir', help='The directory containing the MP3 files')