views:

32

answers:

0

Hello, I try to write a script than scan recursive a given directory and if found mp3 get and just print meta tag for it. What ever I passed to getEyeD3Tag I got an exception. Here is my code that i have written so far

  def getEyeD3Tags(path):
    try:
        trackInfo = eyeD3.Mp3AudioFile(path)
        tag = trackInfo.getTag()
        tag.link(path)
        print tag.getArtist()
        print tag.getAlbum()
        print tag.getTitle()

        #return (tag.getArtist(),tag.getTitle(),tag.getAlbum())
    except eyeD3.InvalidAudioFormatException:
        print "File %s is not a mp3 file " % path
mp3Num=0
temp=os.walk(valid-folder-name)
for root, dirs, files in temp:
    for i in files:
        if os.path.join(root,i):
            temp=os.path.splitext(i)
            temp[1].lower()
            if temp[1]=='.mp3':
                mp3Path=os.path.join(root,i)
                print mp3Path
                getEyeD3Tags(mp3Path)
                mp3Num+=1
                raw_input()
            #print "**"
        else:
            print "Error invalid path"
    print "\n\n"
    #raw_input()
print mp3Num
raw_input()

And BTW is it a way to get genre of mp3 file using eyeD3? Thx in advance