Watch YouTube videos using youtube-dl
Trisquel includes Gnash by default, so YouTube videos should work most of the time. However, watching YouTube videos this way requires the user to run proprietary JavaScript and ActionScript. It also requires more system resources than downloading the videos and viewing them with a video player, such as Totem or SMPlayer.
YouTube videos can be downloaded on Trisquel via yt-dlp. yt-dlp is free software and is capable of downloading videos from YouTube and other video websites.
NOTE: yt-dlp can execute proprietary JavaScript code. A modified version of yt-dlp, AVideo, was written to avoid this.
Installing yt-dlp
- Open Terminal
- Use the following command to download the yt-dlp program:
$ sudo apt install yt-dlp
* Update to a more recent version:$ sudo yt-dlp -U
Do this step whenever yt-dlp stops working due to changes in the YouTube website.
- The first time you update yt-dlp using this method, you will need to run it as root:
$ sudo yt-dlp
Now, you can use the yt-dlp command to download YouTube videos. First, find out which formats are available by using the following command and replacing the shown URL with the URL of the video you wish to download.
$ yt-dlp -F https://www.youtube.com/watch?v=8p9IU4zp7mUThe output will look like this:
[youtube] Confirming age [youtube] 8p9IU4zp7mU: Downloading webpage [youtube] 8p9IU4zp7mU: Downloading video info webpage [youtube] 8p9IU4zp7mU: Extracting video information [youtube] 8p9IU4zp7mU: Downloading DASH manifest [info] Available formats for 8p9IU4zp7mU: format code extension resolution note 139 m4a audio only DASH audio 48k , audio@ 48k (22050Hz), 788.95KiB (worst) 140 m4a audio only DASH audio 127k , audio@128k (44100Hz), 2.06MiB 141 m4a audio only DASH audio 255k , audio@256k (44100Hz), 4.13MiB 160 mp4 192x144 DASH video 112k , video only, 1.79MiB 133 mp4 320x240 DASH video 245k , video only, 3.94MiB 134 mp4 480x360 DASH video 309k , video only, 4.57MiB 135 mp4 640x480 DASH video 545k , video only, 8.59MiB 17 3gp 176x144 36 3gp 320x240 5 flv 400x240 43 webm 640x360 18 mp4 640x360 (best)Unfortunately, the video may come in a patent-encumbered format, like MP4. To receive videos in a free format like WebM, you may use the following command:
$ yt-dlp -f webm https://www.youtube.com/watch?v=8p9IU4zp7mU -o '%(title)s.%(ext)s'The " -o '%(title)s.%(ext)s' " part tells yt-dlp to save the video using the video's original title. More saving options can be found by running "yt-dlp -h"):
yt-dlp will then start downloading the video. The output will look something like this:
[youtube] 8p9IU4zp7mU: Downloading webpage [youtube] 8p9IU4zp7mU: Extracting video information [youtube] 8p9IU4zp7mU: Downloading DASH manifest [download] Destination: Richard Stallman - DRM.webm [download] 100% of 3.88MiB in 00:16
Alternative way for installing/upgrading yt-dlp
There is another way to have yt-dlp installed, using the pip Python package manager/installer:$ sudo install python-pip
$ sudo pip install yt-dlpUpgrading is as simple as
$ sudo pip install -U yt-dlp