3 # usage: mp3tohtml.py [-h] [--config CONFIG] dir
5 # Generate an HTML containing information about the MP3 files.
7 # positional arguments:
8 # dir The directory containing the MP3 files
11 # -h, --help show this help message and exit
12 # --config CONFIG The directory containing the configuration
14 # Last version of this tool can be get from the GIT repository:
15 # http://wpitchoune.net/mp3tohtml
17 # http://wpitchoune.net/mp3tohtml
18 # Released under the terms of the GPLv2 license.
19 # (c) 2016 Jean-Philippe Orsini <jeanfi@gmail.com>
24 parser = argparse.ArgumentParser(description='Generate an HTML containing information about the MP3 files.')
25 parser.add_argument('dir', help='The directory containing the MP3 files')
26 parser.add_argument("--config", help="The directory containing the configuration")
28 args = parser.parse_args()
30 if (args.config is None):
31 cfg_dir = os.path.dirname(sys.argv[0])
38 for root, dirnames, filenames in os.walk(args.dir):
39 for filename in fnmatch.filter(filenames, '*.mp3'):
40 files.append(os.path.join(root, filename))
49 print("\t\t<td>" + tag.getArtist().encode("UTF8") + "</td>\n")
50 print("\t\t<td>" + tag.getAlbum().encode("UTF-8") + "</td>")
51 print("\t\t<td>" + tag.getTitle().encode("UTF-8") + "</td>")
53 comments = tag.getComments()
56 strComments += c.comment
58 p = re.compile("URL: (.*)\r\nComments: (.*)\r\nCurators?: (.*)\r\nCopyright: (.*)")
59 m = p.match(strComments)
66 if m.group(2) == "http://freemusicarchive.org/":
68 url = "<a href=\"" + m.group(1) + "\">FMA</a>"
70 strComments = m.group(2)
71 url = "<a href=\"" + m.group(1) + "\">source</a>"
75 copyright = fma_copyright_to_html(f, m.group(4))
77 print("\t\t<td>" + url + "</td>")
78 print("\t\t<td>" + curator + "</td>")
79 print("\t\t<td>" + copyright + "</td>")
80 print("\t\t<td>" + strComments + "</td>")