Post date: Oct 19, 2016 7:38:51 PM
NOTE: I did not create this method, and the original sources are located at the bottom of this post. I have simplified it, and changed a few things.
First, we'll need to install a few things.
youtube-dl - we're going to install from git-hub because it is the most reliable way to recieve the lastest version.
wget -O - https://yt-dl.org/latest/youtube-dl | sudo tee /usr/local/bin/youtube-dl > /dev/null
sudo chmod a+x /usr/local/bin/youtube-dl
hash -r
Next we need xsel to grab the clipboard, and xdotool to use a keyboard command to hide all other windows.
sudo apt-get update
sudo apt-get install xsel
sudo apt-get install xdotool
Next were going to make a bash script. Type the following...
sudo nano /home/pi/youtube.sh
And copy and paste the following... and "best" can be subsituted for any of the resoultion choices in youtube-dl.
#!/bin/bash
xdotool key ctrl+alt+d
omxplayer -o local "$(youtube-dl -g -f best `xsel`)"
Save the file by pressing control + x and confirm by pressing 'y'.
Next we need to change the permission of the script.
sudo chmod +x /home/pi/youtube.sh
Now we need to make an icon for it.
sudo nano /usr/share/applications/youtube.desktop
And paste this into it.
[Desktop Entry]
Name=Youtube
Comment=GUI for omxplayer
Exec=/home/pi/youtube.sh
Icon=video-display
Terminal=true
Type=Application
Categories=Application;Multimedia;Audio;AudioVideo
Control + x to exit and save, and then we change permissions.
sudo chmod +777 /usr/share/applications/youtube.desktop
Now if you right-click where your app icons are in the toolbar you can go to "Application Launch Bar Settings" and add the icon for the youtube script under video and sound. Now when your browsing youtube, simply copy and link to your clipboard, and click the icon for the script. It will launch the video into omxplayer.
The main controls are
q = quit
space = pause/play
left arrow = skip back 30sec
right arrow = skip 30 sec
There are more controls, but you can google the rest for yourself.
SOURCES:
https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=162850
http://askubuntu.com/questions/194420/youtube-dl-is-not-working