Downloading Youtube Videos with Pytube and Shellmarks

Pytube is a great little Python utility for downloading videos from youtube as .mp4 files. It has a command-line interface that makes downloading videos as simple as entering the following command:

$ pytube https://www.youtube.com/watch?v=….

Pytube is a great little Python utility for downloading videos from youtube as .mp4 files. It has a command-line interface that makes downloading videos as simple as entering the following command:

$ pytube https://www.youtube.com/watch?v=....

Replace the URL with the Youtube URL of the video you want to download.

To make things even easier, I wrote a shellmarks wrapper script for this that provides an intuitive GUI form.

Shellmarks dialog for pytube

Simply paste in the URL and press “Download”, and it will download the video to your “Downloads” directory.



Installation

Pytube installation instructions can be found here.

The TLDR of the install instructions, if you have Python 3 already installed, is to open Terminal and enter:

$ pip install pytube

If pip happens to be the python2 version, you can try

$ pip3 install pytube

instead.

The Shellmarks installation instructions can be found here

The TLDR of the install instructions, if you have npm installed, is to open Terminal and enter:

$ sudo npm install -g shellmarks

I have uploaded the shellmarks wrapper script here

To install it in shellmarks, begin by opening shellmarks by opening Terminal and running

$ shellmarks

After shellmarks opens, open the menu in the upper right corner and select “Import Script from URL”

Shellmarks menu

You will the be prompted to enter the URL to the script:

Shellmarks import script dialog

The URL to the raw script is

https://raw.githubusercontent.com/shannah/shellmarks/master/sample-scripts/pytube.sh

Paste that URL into the field and press “OK”.

This will install the script and refresh the shellmarks catalog. You should now see an entry as follows:

Shellmarks catalog entry for pytube

Press “Run” to run the script. You’ll see the dialog prompting you for the video URL you want to download.

Shellmarks dialog for running pytube

Paste any youtube URL in here and press “Download”. You’ll be able to see the progress of the download in the terminal you used to open shellmarks. When the download is complete, it will open the video in your preferred movie player.

NOTE: This script was developed for MacOS, and would need to be modified slightly to work on Linux or Windows.

You can now access this script directly from within Shellmarks anytime. If you want to run it directly from the command-line you could also simply run:

$ shellmarks pytube



References:

Photo by Alexander Shatov on Unsplash


Print Share Comment Cite Upload Translate
APA
Steve Hannah | Sciencx (2024-03-29T14:22:25+00:00) » Downloading Youtube Videos with Pytube and Shellmarks. Retrieved from https://www.scien.cx/2021/12/22/downloading-youtube-videos-with-pytube-and-shellmarks/.
MLA
" » Downloading Youtube Videos with Pytube and Shellmarks." Steve Hannah | Sciencx - Wednesday December 22, 2021, https://www.scien.cx/2021/12/22/downloading-youtube-videos-with-pytube-and-shellmarks/
HARVARD
Steve Hannah | Sciencx Wednesday December 22, 2021 » Downloading Youtube Videos with Pytube and Shellmarks., viewed 2024-03-29T14:22:25+00:00,<https://www.scien.cx/2021/12/22/downloading-youtube-videos-with-pytube-and-shellmarks/>
VANCOUVER
Steve Hannah | Sciencx - » Downloading Youtube Videos with Pytube and Shellmarks. [Internet]. [Accessed 2024-03-29T14:22:25+00:00]. Available from: https://www.scien.cx/2021/12/22/downloading-youtube-videos-with-pytube-and-shellmarks/
CHICAGO
" » Downloading Youtube Videos with Pytube and Shellmarks." Steve Hannah | Sciencx - Accessed 2024-03-29T14:22:25+00:00. https://www.scien.cx/2021/12/22/downloading-youtube-videos-with-pytube-and-shellmarks/
IEEE
" » Downloading Youtube Videos with Pytube and Shellmarks." Steve Hannah | Sciencx [Online]. Available: https://www.scien.cx/2021/12/22/downloading-youtube-videos-with-pytube-and-shellmarks/. [Accessed: 2024-03-29T14:22:25+00:00]
rf:citation
» Downloading Youtube Videos with Pytube and Shellmarks | Steve Hannah | Sciencx | https://www.scien.cx/2021/12/22/downloading-youtube-videos-with-pytube-and-shellmarks/ | 2024-03-29T14:22:25+00:00
https://github.com/addpipe/simple-recorderjs-demo