Download Youtube Video in Pi
Yes you can download Youtuube videos in Raspberry Pi and use for offline viewing.
Software availabe for downlaoding videos is
youtube-dl
you can install using
apt-get install youtube-dl (run this command as root)
After installing this you can download the video
youtube-dl <youtube URL>
if you want to download in mp4 or any specific format then use the following option
format code extension resolution note
171 webm audio only DASH webm audio , audio@ 48k (worst)
140 m4a audio only DASH audio , audio@128k
160 mp4 192p DASH video
133 mp4 240p DASH video
134 mp4 360p DASH video
135 mp4 480p DASH video
136 mp4 720p DASH video
137 mp4 1080p DASH video
17 3gp 176x144
36 3gp 320x240
5 flv 400x240
43 webm 640x360
18 mp4 640x360
22 mp4 1280x720 (best)
youtube-dl -f 18 <Youtube URL>
This command was not working and giving error in my Pi and asked me to upgrade.
If you get error
[youtube] Setting language [youtube] bzSTpdcs-EI: Downloading webpage [youtube] bzSTpdcs-EI: Downloading video info webpage [youtube] bzSTpdcs-EI: Extracting video information [youtube] bzSTpdcs-EI: Encrypted signatures detected. ERROR: Signature extraction failed: Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/youtube.py", line 479, in _decrypt_signature video_id, player_url, s File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/youtube.py", line 356, in _extract_signature_function raise ExtractorError('Cannot identify player %r' % player_url) ExtractorError: Cannot identify player u'/yts/jsbin/player-vflAAoWvh/en_US/base.js'; please report this issue on https://yt-dl.org/bug . Be sure to call youtube-dl with the --verbose flag and include its complete output. Make sure you are using the latest version; type youtube-dl -U to update. ; please report this issue on https://yt-dl.org/bug . Be sure to call youtube-dl with the --verbose flag and include its complete output. Make sure you are using the latest version; type youtube-dl -U to update.
You need to upgrade youtube-dl, you can use following command
root@raspberrypi:~# youtube-dl -U It looks like you installed youtube-dl with a package manager, pip, setup.py or a tarball. Please use that to update. root@raspberrypi:~#
If you get above error then
try running command pip if it gives error and pip is also not installed then install pip and upgrade youtube-dl
root@raspberrypi:~# pip -su: pip: command not found root@raspberrypi:~# apt-get install python-setuptools Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: python-setuptools 0 upgraded, 1 newly installed, 0 to remove and 28 not upgraded. Need to get 242 kB of archives. After this operation, 770 kB of additional disk space will be used. Get:1 http://mirrordirector.raspbian.org/raspbian/ jessie/main python-setuptools all 5.5.1-1 [242 kB] Fetched 242 kB in 1s (200 kB/s) Selecting previously unselected package python-setuptools. (Reading database ... 35818 files and directories currently installed.) Preparing to unpack .../python-setuptools_5.5.1-1_all.deb ... Unpacking python-setuptools (5.5.1-1) ... Setting up python-setuptools (5.5.1-1) ... root@raspberrypi:~# easy_install pip Searching for pip Reading https://pypi.python.org/simple/pip/ Best match: pip 9.0.1 Downloading https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9 Processing pip-9.0.1.tar.gz Writing /tmp/easy_install-HWeUGq/pip-9.0.1/setup.cfg Running pip-9.0.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-HWeUGq/pip-9.0.1/egg-dist-tmp-yuuYOs /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'python_requires' warnings.warn(msg) warning: no previously-included files found matching '.coveragerc' warning: no previously-included files found matching '.mailmap' warning: no previously-included files found matching '.travis.yml' warning: no previously-included files found matching '.landscape.yml' warning: no previously-included files found matching 'pip/_vendor/Makefile' warning: no previously-included files found matching 'tox.ini' warning: no previously-included files found matching 'dev-requirements.txt' warning: no previously-included files found matching 'appveyor.yml' no previously-included directories found matching '.github' no previously-included directories found matching '.travis' no previously-included directories found matching 'docs/_build' no previously-included directories found matching 'contrib' no previously-included directories found matching 'tasks' no previously-included directories found matching 'tests' Adding pip 9.0.1 to easy-install.pth file Installing pip script to /usr/local/bin Installing pip2.7 script to /usr/local/bin Installing pip2 script to /usr/local/bin Installed /usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg Processing dependencies for pip Finished processing dependencies for pip root@raspberrypi:~# pip install --upgrade youtube-dl Collecting youtube-dl Downloading youtube_dl-2017.8.18-py2.py3-none-any.whl (1.6MB) 100% |████████████████████████████████| 1.6MB 76kB/s Installing collected packages: youtube-dl Found existing installation: youtube-dl 2014.8.5 DEPRECATION: Uninstalling a distutils installed project (youtube-dl) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project. Uninstalling youtube-dl-2014.8.5: Successfully uninstalled youtube-dl-2014.8.5 Successfully installed youtube-dl-2017.8.18
After all above steps you can download videos
youtube-dl -f 10 <URL>
it will download the videos, after download you can view
omxplayer <Video_downloaded>