-
-
Save mattwellss/a88a0e50643fc7f4a243 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 bash | |
| if ! pgrep -q Rdio | |
| then | |
| echo "Error: Rdio is not running"; exit 1 | |
| fi | |
| function check { | |
| which "$1" || echo "Missing dep: $1"; exit 1 | |
| } | |
| # check deps | |
| CUT=$(check cut) | |
| SED=$(check sed) | |
| GREP=$(check grep) | |
| CURL=$(check curl) | |
| RDIO=$(check rdio) | |
| CURRENT=$($RDIO current | $CUT -d: -f2-) | |
| ARTIST=$(echo "$CURRENT" | $CUT -d'/' -f2) | |
| SONG=$(echo "$CURRENT" | $CUT -d'/' -f1) | |
| YOUTUBE="https://www.youtube.com" | |
| LINK="$YOUTUBE/results?search_query=" | |
| URI=$(echo "$ARTIST-$SONG, hd" | $SED -r 's/ /+/g') | |
| SEARCH=$($CURL -s "$LINK$URI" | $GREP -o 'href=\"/watch?v=.*\"' -m1 | $CUT -d'"' -f2) | |
| open "$YOUTUBE$SEARCH" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment