python mp3 meta-tag -
i try write script scan recursive given directory , if found mp3 , print meta tag it. ever passed geteyed3tag got exception. here code have written 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 not mp3 file " % path mp3num=0 temp=os.walk(valid-folder-name) root, dirs, files in temp: 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 way genre of mp3 file using eyed3? thx in advance
to check if file being parsed valid mp3, call eyed3.ismp3file(filename) method.
the following short script made auto-sort music folder.
def parseidetag(self, path): if eyed3.ismp3file(path):
that way, if file isn't mp3, it'll skip on it.
also, str(tag.getgenre())
returns genre string using eyed3.
Comments
Post a Comment