Skip to content

Instantly share code, notes, and snippets.

@SenpaiSilver
Created August 8, 2016 18:16
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 SenpaiSilver/951278707b10bedadd8133c65785f430 to your computer and use it in GitHub Desktop.
Save SenpaiSilver/951278707b10bedadd8133c65785f430 to your computer and use it in GitHub Desktop.
#!/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