Skip to content

Instantly share code, notes, and snippets.

@siers
Created March 11, 2013 10:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siers/5133295 to your computer and use it in GitHub Desktop.
Save siers/5133295 to your computer and use it in GitHub Desktop.
find me some jazz from reddit, requires ack, zsh
#!/bin/zsh
surl="http://www.reddit.com/r/jazz/search?q=%s&restrict_sr=on&sort=relevance&t=all"
url="http://www.reddit.com/r/jazz/"
find() {
curl -s $1 | ack -o "https?://(www.)?youtu[^'\"&]+"
}
parse() {
if [ -z "$1" ]; then
echo $url
else
echo "$(printf "$surl" "$1")"
fi
}
title() {
curl -Ls $1 | ack -o "(?<=<title>)[^<]+"
}
output() {
echo "$1: $( title $1 )"
open $1
}
output $(find $(parse) | shuf | head -n1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment