-
-
Save siers/5133295 to your computer and use it in GitHub Desktop.
find me some jazz from reddit, requires ack, zsh
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
#!/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