MPlayer youtube script: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(remove dependencies on grep, awk and tr - beautify a little) |
||
Line 14: | Line 14: | ||
#!/bin/bash | #!/bin/bash | ||
if [ -z "$1" ] | if [ -z "$1" ] | ||
then | |||
echo "usage: $0 <youtube-URL> [mplayer args]" | |||
exit | |||
fi | |||
url=$1 | url="$1" | ||
shift | shift | ||
echo \"http://www.youtube.com/get_video?video_id= | echo \"http://www.youtube.com/get_video?video_id=$(wget -q -O - "$url" \ | ||
| sed -e '/fullscreenUrl/!d' \ | |||
-e 's/.*video_id=//' \ | |||
-e 's/ /_/g' \ | |||
-e "s/[';]//g" \ | |||
)\" \ | |||
| xargs mplayer "$@" | |||
</pre> | </pre> | ||
created by enouf and n3kl and amphi | created by enouf and n3kl and amphi | ||
modified by Elte |
Revision as of 02:38, 14 August 2008
bash script for playing youtube videos
- save it as youtube.sh
- chmod +x youtube.sh
- place it somewhere in PATH (like /usr/local/bin )
Usage:
- youtube.sh <url> [mplayer args]
- youtube.sh http://www.youtube.com/watch?v=example -dumpstream -dumpfile something.flv
- youtube.sh http://www.youtube.com/watch?v=example -aspect 16:9
- youtube.sh http://www.youtube.com/watch?v=example -xy 2
#!/bin/bash if [ -z "$1" ] then echo "usage: $0 <youtube-URL> [mplayer args]" exit fi url="$1" shift echo \"http://www.youtube.com/get_video?video_id=$(wget -q -O - "$url" \ | sed -e '/fullscreenUrl/!d' \ -e 's/.*video_id=//' \ -e 's/ /_/g' \ -e "s/[';]//g" \ )\" \ | xargs mplayer "$@"
created by enouf and n3kl and amphi
modified by Elte