How I Watch YouTube on my PiRaspberry Pi Guide 100DaysToOffload
(originally posted on github)
Are you a YouTube surfer or do you only watch a few different YouTubers?
I am the latter. If you like to browse and discover new videos then you can stop reading. This little guide will not be of interest to you.
- something that can play videos, I use mpv, if you use VLC you will have to modify the steps by yourself
- recent version of youtube-dl
- (optional) a terminal web browser like lynx, elinks, links2 or w3m
- a little patience
READ THROUGH ALL OF THE STEPS BEFORE YOU BEGIN
$ sudo apt-get install mpv newsboat youtube-dl lynx elnks links2 w3m
(you do not need all of those browsers, and if you prefer VLC you do not need to install mpv)
You now have newsboat which is a terminal-based feedreader. Imagine Google Reader but in your terminal. If you open your terminal (ALT+CTRL+T) you can type
newsboat nothing will happen. You need to set up your url list and a few other things.
- mpv configuration
create the file /home/pi/.config/mpv/mpv.conf and paste the code below into it:
#Sets window to middle of screen with no border no-border geometry=50%x50% geometry=50%:50% #youtube settings ytdl-format=best[height=720]
- newsboat configuration
create the file /home/pi/.newsboat/config and paste the following code below into it:
# BASICS refresh-on-startup yes auto-reload yes reload-time 5 reload-threads 5 feedlist-format "%4i %n %11U %t" browser "/usr/bin/elinks" #you can set this to chromium or firefox if you prefer, or just set it to mpv or vlc if you never plan on using newsboat to read RSS feeds keep-articles-days 30 save-path "~/Documents/Articles" # MACROS macro y set browser "mpv %u"; open-in-browser ; set browser "/usr/bin/elinks %u" #this is what make newsboat open YouTube links macro f set browser "firefox %u"; open-in-browser ; set browser "/usr/bin/elinks %u" #this will open a link in firefox instead of the text browser
now create the file /home/pi/.newsboat/urls
This file contains the YouTube channels you want to watch and is the annoying part.
Here is a section of my urls file:
###### # YT # ###### https://www.youtube.com/feeds/videos.xml?channel_id=UCsXVk37bltHxD1rDPwtNM8Q https://www.youtube.com/feeds/videos.xml?channel_id=UCr3cBLTYmIK9kY0F_OdFWFQ https://www.youtube.com/feeds/videos.xml?channel_id=UC2C_jShtL725hvbm1arSV9w https://www.youtube.com/feeds/videos.xml?channel_id=UC1DTYW241WD64ah5BFWn4JA https://www.youtube.com/feeds/videos.xml?channel_id=UCHsRtomD4twRf5WVHHk-cMw
You now need to find the channel ID of the different channels you watch.
Go to the channel page of one of your favourites and view the source of the page. In Firefox you can right-click and choose “View Page Source”
Press CTRL+F and search for
title="RSS" href= and you should find the RSS link for the page.
Copy that link and add it to your urls file.
Put each channel feed on a new line. Save the file. Launch newsboat in the terminal to seee if things load up. If it looks good, quit. There is another little step to take care of.
- getting the latest youtube-dl
You have already installed youtube-dl but you should get it up to date now.
This is a pretty easy step and the instructions are on the youtube-dl homepage link.
Open up your terminal and, copy and paste this line and launch:
$ sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl $ sudo chmod a+rx /usr/local/bin/youtube-dl
Now youtube-dl is ready to go.
Time to try this out.
Open your terminal and run newsboat. I have also subscribed to non-YouTube feeds. You can see my YouTube subscriptions in the yellow block:
Everything should refresh when you launch and you will see if there are new videos. Choose a channel. Press ENTER to see the feed from that channel.
On my example it looks like this:
Choose the latest unseen video. Again, my example:
Now you have a choice:
A) you can press ‘O’ and nothing much will happen unless you have modified the config file to set your browser to chromium or firefox.
B) you can use your mouse to right-click and open the link which will launch your regular default browser.
C) you can use the macro that we set up earlier and press ‘,’ (that’s a comma, it tells newsboat that a macro is coming) and then press ‘y’ for YouTube. Wait a second and mpv will launch the video.
I like option C.
Now the video is running. There are a few commands to remember, but truly, the most important is ‘q’ for quit. The other commands you can look up later (cf. references)