Skip to content

Instantly share code, notes, and snippets.

@qqueue
Created March 17, 2016 05:33
Show Gist options
  • Save qqueue/1a28ded4d05a9fdf6667 to your computer and use it in GitHub Desktop.
Save qqueue/1a28ded4d05a9fdf6667 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# >streaming
# https://stedolan.github.io/jq/
# https://github.com/ericchiang/pup
# https://github.com/thoughtbot/pick
# https://github.com/mafintosh/peerflix
declare -A torrents
while IFS="=" read -r name magnet; do
torrents[$name]=$magnet
done < <(\
curl -s "http://horriblesubs.info/lib/search.php?value=$1" |\
pup '.release-links json{}' |\
jq -r ".[] |\
{name: .children[0].children[0].children[0].children[0].children[0].text, \
value: .children[0].children[0].children[0].children[1].children[0].children[0].href} |\
select(.name | contains(\"720p\")) |\
\"\(.name)=\(.value)\"")
selected=$(printf '%s\n' "${!torrents[@]}" | sort -r | pick)
if [[ -n "${selected// }" ]]; then
magnet=${torrents[$selected]}
peerflix --mpv --not-on-top "$magnet"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment