RPIYT / 2013-04-29 04:09:45

Playing YouTube video on a RPI is possible directly from the Linux command-line, without having even to start X. It saves some resources. There are many tutorials (see 1, 2 for example) on how to install YouTube but I found that the information was spread all over, so here is a summary:

  1. Install youtube-dl (and update it) to download YouTube video:

    sudo apt-get update
    sudo apt-get install youtube-dl
    sudo youtube-dl -U
  2. Install Python setup tools, needed to install whitey:

    sudo apt-get install python-setuptools
  3. Download whitey, which is the "front-end" to YouTube:

    wget http://pypi.python.org/packages/source/w/whitey/whitey-0.1.tar.gz
    tar -zxvf whitey-0.1.tar.gz
  4. If you want to use omxplayer instead of mplayer, edit whitey init file:

    nano whitey-0.1/src/yt/__init__.py
    CTRL+W to search for mplayer
    Replace mplayer by omxplayer and remove mplayer switches

  5. Install whitey and start playing YouTube videos:

    sudo python setup.py install
    yt

If yt does not play the videos that you choose, make sure that youtube-dl is working properly by running the command:

youtube-dl http://www.youtube.com/watch?v=-KMpZaEF6g0

which should result in:

[youtube] Setting language
[youtube] -KMpZaEF6g0: Downloading video webpage
[youtube] -KMpZaEF6g0: Downloading video info webpage
[youtube] -KMpZaEF6g0: Extracting video information
[download] Destination: -KMpZaEF6g0.mp4
[download]   X% of 118.89M at  AAA.BBBk/s ETA MM:SS

where X, AAA.BBB, and MM:SS depend of course on how the download is going If the command returns an error, then sudo youtube-dl -U.