User Tools

Site Tools


ytvp

YouTube Video Player

Description

My attempt at removing the nasty Flash dependency for YouTube streaming. What this does is disables Flash if the domain is youtube.com, and launches mplayer in fullscreen mode to stream the video on the current webpage.

Script

#!/bin/bash
# YouTube Video Player
# Required: uzbl, youtube-dl, mplayer

# Uncomment one of these modes.
#FORMATS=()   # Play SD quality.
FORMATS=(22 18 6) # Play best HD quality available.
#FORMATS=(6 18 22) # Play worst HD quality available.

# Settings
MPLAYER_COMMAND=(mplayer -really-quiet -fs)
VALID_URL=0
exec &>/dev/null

# Disable browser plugins on video pages.
if echo "$6" | grep "http://www.youtube.com"; then
  echo "set disable_plugins = 1" > "$4"
else
  echo "set disable_plugins = 0" > "$4"
fi

# Plays the first format found.
if fgrep 'http://www.youtube.com/watch' -q <<< "$6"; then
  VALID_URL=1
  for f in "${FORMATS[@]}"; do
    URL=$(youtube-dl -f "$f" -g "$6")
    if [[ $URL ]] ; then
      "${MPLAYER_COMMAND[@]}" "$URL"
      exit
    fi
  done
fi

if [[ $VALID_URL = 1 ]]; then
  "${MPLAYER_COMMAND[@]}" "$(youtube-dl -g "$6")"
fi

Installation

Save the script above to your uzbl scripts directory, usually $XDG_DATA_HOME/uzbl/scripts, chmod +x it, and add it to uzbl's config as follows:

set load_finish_handler = chain 'set status_message = ...' 'spawn $XDG_DATA_HOME/uzbl/scripts/ytvp.sh $4 $6'

Usage

1) Follow install instructions above. 2) Uncomment the top of the script to select the video quality. 3) Reload uzbl and browse to a YouTube video page.

Note: It may take afew seconds to buffer the stream depending on the quality you uncommented and your internet connection.

ytvp.txt · Last modified: 2016/08/31 14:10 (external edit)