Created
April 7, 2011 16:00
-
-
Save inky/908069 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# Get a quasi-random list of band names, album names and track names from your | |
# iTunes folder. Tastes great with Orothron <http://github.com/inky/orothron>. | |
import os | |
import re | |
itunes_tracknum = re.compile(r'^[0-9]+(-[0-9]+)?\ ') | |
def filter_name(name): | |
if itunes_tracknum.match(name): | |
name = name[name.index(' ') + 1:] | |
return os.path.splitext(name)[0] | |
filter_names = lambda L: [filter_name(n) for n in L] | |
def filenames(path='~/Music/iTunes/iTunes Music/Music'): | |
path = os.path.expanduser(path) | |
names = set() | |
for _, dirs, files in os.walk(path): | |
names.update(filter_names(dirs)) | |
names.update(filter_names(files)) | |
return names | |
def main(): | |
print '\n'.join(filenames()) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment