-
-
Save Katamori/c43dfe65d464eebcbc7a3567d28a0cb8 to your computer and use it in GitHub Desktop.
youtube viewer in bash
This file contains hidden or 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
# usage ./yt.sh <https://youtube.com/watch?v=....> | |
urldecode() { | |
local url_encoded="${1//+/ }" | |
printf '%b' "${url_encoded//%/\\x}" | |
} | |
video_url="$1" | |
raw_url=$(curl \ | |
-H 'Upgrade-insecure-requests: 1' \ | |
-H 'Cache-control: max-age=0' \ | |
-H 'Accept-language: en-US,en;q=0.8,bn;q=0.6' \ | |
-H 'Accept-encoding: gzip, deflate, sdch' \ | |
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' \ | |
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36' \ | |
"${video_url}" \ | |
| gunzip \ | |
| egrep -o 'https%3A%2F%2F[^\.]*\.googlevideo.com%2F[^,\]*' \ | |
| head -n 1) | |
mplayer $(urldecode "$raw_url") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment