Post by merkur32123 on Aug 22, 2011 9:56:51 GMT -5
Kris told in one of his videos, he would show us how to make a script, that will stream videos from YouTube into mPlayer. At least i didn't find it on his YouTube Chanel, so i figured out he never made it. So, i just made my own script and decided to share it with you guys!
And here is a quickly made zenity front-end for it!
Once again, The video may exist. If it does, you may call me a Dumbass.
#!/usr/bin/env bash
if [ "$UID" == "0" ]
then
echo "NOTE: This script is not meant to be ran as root"
fi
link=$1
let x=0
if [ "$link" != "" ]
then
if [ "$(echo "$link"|cut -d"=" -f1 -)" != "http://www.youtube.com/watch?v" ]
then
echo -e "\nSimple YouTube to mPlayer streaming Script"
if [ "$link" != "--help" ]
then
echo "ERROR: No such available option: $1!"
let x=1
fi
echo -e "Usage: $0 [OPTION]\n\nSince this script is made by a really dumb person, you can only specify one option at time.\nAvailable options are:\n\n\t<YouTube link>\t Plays the supplied YouTube link\n\t--help\t\t Displays this help\n\nBy default, if no option is specified, The script will ask you for a YouTube link.\n"
exit $x
fi
fi
TMPDIR="/tmp/YouTube-to-mPlayer"
while [ "$link" == "" ]
do
echo "Paste your YouTube link below!"
read link
if [ "$(echo "$link"|cut -d"=" -f1 -)" != "http://www.youtube.com/watch?v" ]
then
if [ "$link" == "" ]
then
let x=1
exit $x
fi
echo "\"$link\" Is not a YouTube Link"
link=""
fi
done
link=$(echo "$link"|cut -d"&" -f1 -)
let x=0
mkdir "$TMPDIR"
mplayer -cookies -cookies-file "$TMPDIR/cookie.txt" $(youtube-dl -gf 34 --cookies "$TMPDIR/cookie.txt" "$link")
rm -rf "$TMPDIR"
exit $x
And here is a quickly made zenity front-end for it!
#!/usr/bin/env bash
while :
do
let x=0
link=$(zenity --entry --text "Insert YouTube link:" --title="Link Input")
if [ "$(echo "$link"|cut -d"=" -f1 -)" != "http://www.youtube.com/watch?v" ]
then
if [ "$link" == "" ]
then
let x=1
exit $x
fi
zenity --error --text "\"$link\" Is not a YouTube Link"
link="--gui"
else
break
fi
done
if [ -f ./YouTube-to-mPlayer.sh ]
then
./YouTube-to-mPlayerr.sh "$link"
fi
exit $x
Once again, The video may exist. If it does, you may call me a Dumbass.