1 |
#!/usr/bin/env python |
2 |
# Decentralized Media |
3 |
# |
4 |
# Douglas Thrift |
5 |
# |
6 |
# $Id$ |
7 |
|
8 |
import eyeD3, sys |
9 |
|
10 |
path = sys.argv[1] |
11 |
|
12 |
def encode(string): |
13 |
string = string.replace("&", "&") |
14 |
string = string.replace("<", "<") |
15 |
string = string.replace("\"", """) |
16 |
string = string.replace(">", ">") |
17 |
return string.encode("utf_8", "xmlcharrefreplace") |
18 |
|
19 |
print """<file> |
20 |
<path>%s</path>""" % (encode(path)) |
21 |
|
22 |
if eyeD3.isMp3File(path): |
23 |
tag = eyeD3.Tag() |
24 |
tag.link(path) |
25 |
print u"""<artist>%s</artist> |
26 |
<title>%s</title> |
27 |
<album>%s</album> |
28 |
<genre>%s</genre>""" % (encode(tag.getArtist()), encode(tag.getTitle()), encode(tag.getAlbum()), encode(tag.getGenre().getName())) |
29 |
|
30 |
print "</file>" |