Skip to content

Instantly share code, notes, and snippets.

@evan-goode
Created January 17, 2020 03:45
Show Gist options
  • Save evan-goode/e5be9dc51d8e5fc78b91db208dad4427 to your computer and use it in GitHub Desktop.
Save evan-goode/e5be9dc51d8e5fc78b91db208dad4427 to your computer and use it in GitHub Desktop.
#!/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