Skip to content

This program is a python script that download the highest available quality of YouTube video up to 1080p (as my laptop did not support anything bove that). This program use pytube library: https://pytube.io/en/latest/

License

Notifications You must be signed in to change notification settings

perfect-less/Python-YouTube-Downloader

Repository files navigation

Python YouTube Downloader - pytd

This program is a python packages with command line interface to download the highest available quality of non progressive YouTube video up to specified maximum resolutions (by default is 1080p). This program was made using Pytube and also ffmpeg to combine and convert media files.

Example

To download youtube video in default directory you just need to type pytd followed by YouTube Video's URL like this command:

$ pytd https://youtu.be/dQw4w9WgXcQ

it's also possible to downloads more than one files at a time, just paste all of YouTube video's URLs you want to download separated by spaces

$ pytd https://youtu.be/dQw4w9WgXcQ https://youtu.be/4MoRLTAJY_0

Download to the current working directory

if you want to download it to current working directory you can do it by just adding -d flag

$ pytd -d https://youtu.be/dQw4w9WgXcQ

Select either audio, video, or both

Sometimes you don't really want to download both video and audio, maybe you only want audio because you just want to listen to the music. By default pytd will download both audio and video then merge it into one .mp4 file after it was downloaded. You can download only audio by using -a flag, pytd then will convert that audio file to .mp3

$ pytd -a https://youtu.be/dQw4w9WgXcQ

to only downloading video, use -v tag

$ pytd -v https://youtu.be/dQw4w9WgXcQ

These tags can be joined together, for example if you want to download only audio file to the current working directory you can use the following command:

$ pytd -da https://youtu.be/dQw4w9WgXcQ

Changing Configurations

If you want to change something like maximum resolutions, audio bitrate, or video codec you can use pytd --set-config [OPTION] [NEW VALUE] command. Although you need to know what options are available first.
To do this, use

$ pytd --config list

to list all available options.

You can also see what the current value of specific option, for example:

$ pytd --config max_res
>>> 1080

And if you want to change maximum resolution to 720p you just have to type:

$ pytd --set-config max_res 720
>>> max_res Updated to 720

Reset Configurations

To reset configuration back to default, you can use the following command:

$ pytd --set-config default
>>> [path to pytdconfig.ini] were reset to default

Note: this will delete your old configuration and replace it with the default one, make sure that you know this before yout do it.

Motivation

I made this program to make my life easier whenever I want to download videos from YouTube. Although there are plenty of web based service for downloading YouTube videos, I always feels the process of opening their website and selecting the video quality are a bit slow and honestly quite tedious, because I'm usually always downloads more than one video at a time. If by any chances you want to try this program, I hope you'll like it.

Installation

Requirements

This program were made using python language using pytube API and ffmpeg for processing media files. Hence this program required:

  • Python 3.8 or above
  • Python pip already installed
  • pytube
  • git
  • ffmpeg

if you haven't installed python and pip yet, you can follow guide available at official websites of python here: https://www.python.org/

For Linux

Many linux distro already come pre-installed with python (and also pip), git, and ffmpeg. If any of the three haven't been installed in your machine, you could look at your distro's repositories for those packages and install it from there. Because we will using pip for the installation, pytube will automatically installed when we install pytd.

If all the pre-requisites already met, then you can install pytd with the following command:

$ python -m pip install git+https://github.com/perfect-less/Python-YouTube-Downloader

or

$ pip install git+https://github.com/perfect-less/Python-YouTube-Downloader

For Windows (Manual Installation)

NOTE: To make installation in windows easier, I did make batch installation scripts which you could download from the release section of this repo. Follow instructions on "For Windwows (Installation with Scripts)."

The first thing to do for windows installation is to install python and pip (please follow the guidance at https://www.python.org/). But since windows didn't come pre-installed with ffmpeg. We need to install it ourself and then add it to our PATH variables.

Installing ffmpeg

  1. Download ffmpeg for windows here: https://ffmpeg.org/download.html
  2. Extract it somewhere on your computer
  3. find the bin folder inside extracted folder from step 2, note the path to said bin folder
  4. Click on Start Menu -> Settings -> System -> About
  5. Click System Info and then Advance System Settings
  6. Click on Environment Variables...
  7. Select Path on the upper section and then click Edit
  8. Click New and then click Browse, add the path to bin folder in the step number 3
  9. Ok on everything and congratulations, now ffmpeg was added to the Path
  10. You can confirm it by opening command-prompt and type ffmpeg --version

Installing pytd with git

We also need git to install the program which can be downloaded from https://git-scm.com/

With all prerequisites met, we can install pytd with the following command:

$ python -m pip install git+https://github.com/perfect-less/Python-YouTube-Downloader

For Windows (Installation with Scripts)

You still need to install python and pip first for this install process to work.

Please download the installation scrips on the release section of this repository. After you've downloaded the installation scrips, please follow these steps:

  1. Extract the zip file into your computer
  2. Enter the pytd install folder
  3. Run PYTD_INSTALLER.bat, you can run it in cmd or just double click on it.
  4. Follow the instructions on the scrips until it finished

To uninstall pytd you have to run the PYTD_UNINSTALL.bat as Administrator.

About

This program is a python script that download the highest available quality of YouTube video up to 1080p (as my laptop did not support anything bove that). This program use pytube library: https://pytube.io/en/latest/

Resources

License

Stars

Watchers

Forks

Packages

No packages published