Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
Omitting results with id3reader [Beginner]
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Ionis, post: 3168052"] Hey guys, hope you can help me here. I've been playing with python for about a week or two and I've been reading "A Byte Of Python" to get me on my feet. I've decided to write a program which will list all ID3 information in a directory of .mp3 files into a .html file. The python script I'm using for this, along with album art (Example) are in the same directory as the music. The output I am getting when it reads these files is "None" so I tried to set up a way to get rid of these results and move onto the next file. The omitting I'm attempting is within the If statement half way down the code, easy to find. Could anyone point me in the right direction on how to stop these "None" results showing in the result .html file. Thanks in advance. ========== import os import id3reader songartist = str("") songtrack = str("") html_bulkadd = str("") html_start = str(""" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// [URL="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"]www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd[/URL]"> <html xmlns="[URL]http://www.w3.org/1999/xhtml[/URL]"> <title>Test Document</title> </head> <body> """) html_end = str(""" </body> </html> """) output = file("output.html", "w") output.write("") output.write(html_start) output.close path = "" dirList = os.listdir(path) for fname in dirList: songartist = str("") songtrack = str("") id3r = id3reader.Reader(fname) if id3r.getValue('performer') == "None": break elif id3r.getValue('title') == "None": break else: songartist = id3r.getValue('performer') songtrack = id3r.getValue('title') output = file("output.html", "a") output.write("<p>" + str(songartist) + " - " + str(songtrack) + "</p>\n") output.close output = file("output.html", "a") output.write("\n"+html_end) output.close ========== If anyone is curious on the module you can find it here: [URL]http://nedbatchelder.com/code/modules/id3reader.html[/URL] [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
Omitting results with id3reader [Beginner]
Top