Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def traverse(self,directory):
- """
- Processes a filelist from findMP3s, building the musicLibrary from metadata.
- """
- u = Utils()
- results = {}
- files = []
- for root, subFolders, file in os.walk(directory):
- for f in file:
- if f.endswith(".mp3"):
- files.append(os.path.join(root,f))
- for f in files:
- filePath = os.path.join(directory, f)
- try:
- audio = EasyID3(filePath)
- artist = unicode(audio["artist"][0])
- title = unicode(audio["title"][0])
- album = unicode(audio["album"][0])
- if not results.has_key(artist):
- results[artist] = {}
- if not results[artist].has_key(album):
- results[artist][album] = []
- results[artist][album].append([filePath,title])
- except KeyError:
- print "MP3 missing artist, title or album: " + filePath
- except EOFError:
- print "ID3 table corrupted: " + filePath
- except IOError:
- print "IOError (UTF getting in the way): " + filePath
- return results
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement