3
# Launch a web browser with the chat pop-out for a YouTube live stream.
9
__DEFAULT_BROWSER=xdg-open
14
echo "launch_youtube_chat.sh <YouTube-URL> [optional options]"
16
echo " Takes the provided URL for a YouTube Live Stream and starts a"
17
echo " web browser pointing to the address of the chat for that stream."
20
echo " --help Display this help message."
23
echo " --browser <browser> Use <browser> as the web browser instead"
24
echo " of default as provided by xdg-open."
29
function __parse_youtube_url {
30
__YOUTUBE_URL=$(echo $1 | sed -r 's/^.*[&?]v=(.{11})([&#].*)?$/\1/')
33
function __parse_args () {
36
echo "Try --help or -h."
47
__DEFAULT_BROWSER="$2"
56
if [[ "$__YOUTUBE_URL" == "" ]]
58
__parse_youtube_url $1
60
echo "Did you try to set the URL twice?"
61
echo "Please run with --help for usage."
73
if [[ "$__YOUTUBE_URL" == "" ]]
76
echo "Please run with --help for usage."
83
#echo "Browser: " $__DEFAULT_BROWSER
84
#echo "YouTube video-id: " $__YOUTUBE_URL
87
__final_url="https://www.youtube.com/live_chat?is_popout=true&v=""${__YOUTUBE_URL}"
91
$__DEFAULT_BROWSER $__final_url