Created
January 17, 2020 03:45
-
-
Save evan-goode/e5be9dc51d8e5fc78b91db208dad4427 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/env python3 | |
import glob | |
import itertools | |
import os | |
import random | |
import subprocess | |
import sys | |
[_, *directories] = sys.argv | |
directories = directories or ["."] | |
def get_files(directories): | |
globs = (glob.iglob(os.path.join(directory, "*")) for directory in directories) | |
items = list(itertools.chain.from_iterable(globs)) | |
return [item for item in items if os.path.isfile(item)] | |
while True: | |
input("Yay Good Job Press Enter!!!") | |
f = random.choice(get_files(directories)) | |
subprocess.call(["afplay", f]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment