Created
August 8, 2016 18:16
-
-
Save SenpaiSilver/951278707b10bedadd8133c65785f430 to your computer and use it in GitHub Desktop.
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/bash | |
function get_format() | |
{ | |
for elem in "${FMT[@]}"; do | |
if (echo ${elem} | grep $1); then | |
echo ${elem} | |
return | |
fi | |
done | |
echo "" | |
} | |
if [ $# -lt 1 ]; then | |
echo You need to specify a YouTube URL. 1>&2 | |
exit 1 | |
fi | |
rray=("480" "360" "240") | |
FORMATS=$(quvi -F $1 2> /dev/null | sed -r 's/\s.*//') | |
IFS='|' read -ra FMT <<< "${FORMATS}" | |
for i in "${rray[@]}"; do | |
PLAYBACK_FMT="$(get_format $i)" | |
if [ "" != "${PLAYBACK_FMT}" ]; then | |
echo "Will play format: ${PLAYBACK_FMT}" 1>&2 | |
mpv $1 --quvi-format=${PLAYBACK_FMT} | |
exit 0 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment