A simple python script and it's used for mp4 type video downloading from youtube.

Overview

Youtube Video Downloader Python Script

Build


Description

This is a simple python script and it's used for mp4 type video downloading from youtube. also, it's used inbuilt python module "pytube". Furthermore, I know we have so many apps and online websites to do the same thing so it's just an experiment to study how to do those things in python.


Feature

  • Easy to download youtube videos
  • You can choose a video format would you like
  • MPEG4 format video

Pre-Requests

  • python 3.x
  • python3-pip

How to Install Python (for windows)

once you have installed git bash then please use your windows command prompt with limited linux commands

Pre-Requests (for RedHat-based-Linux)

yum install -y git
yum install -y python3
yum install -y python3-pip

Pre-Requests (for Debian-based-Linux)

apt install -y git
apt install -y python3
apt install -y python3-pip

Pre-Requests (for Termux-based-Linux)

pkg upgrade
pkg install git
pkg install python3
pkg install pip

using termux who you guys please install requirements use pip install -r requirements.txt don't need to use pip3


Modules Used


How to Get

git clone https://github.com/yousafkhamza/youtube-video-downloader-pyscript.git
cd youtube-video-downloader-pyscript
pip3 install -r requirements.txt

How to execute

python3 youtube_downloader.py

Output be like

dir Downloads Volume in drive C is Windows Directory of C:\Users\yousa\youtube-video-downloader-pyscript\Downloads 01/10/2022 08:49 AM 13,601,616 Thathaka Theithare Video Song Hridayam Pranav Vineeth Prithviraj Hesham Visakh Merryland.mp4 C:\Users\yousa\youtube-video-downloader-pyscript>">
C:\Users\yousaf>git clone https://github.com/yousafkhamza/youtube-video-downloader-pyscript.git
Cloning into 'youtube-video-downloader-pyscript'...
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 9 (delta 2), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (9/9), done.
Resolving deltas: 100% (2/2), done.

C:\Users\yousaf>cd youtube-video-downloader-pyscript

C:\Users\yousaf\youtube-video-downloader-pyscript>pip3 install -r requirements.txt
Collecting pytube
  Downloading pytube-11.0.2-py3-none-any.whl (56 kB)
     |████████████████████████████████| 56 kB 654 kB/s
Installing collected packages: pytube
Successfully installed pytube-11.0.2

C:\Users\yousaf\youtube-video-downloader-pyscript>python3 youtube_downloader.py
Youtube URL: https://youtu.be/gJB3l7uc4RA                            <------------------- URL pasted here.

Fetching "Thathaka Theithare Video Song | Hridayam | Pranav | Vineeth | Prithviraj | Hesham |Visakh |Merryland"..
Information:
Highest Resolution: 720p
Author: Think Music India
Views: 1,312,619

Available Formats:
['360p', '720p']
Choose one format would you like to download (eg:360p): 720p        <------------------- Choose any resolution when available here.

Information about the video format you had selected:
File size: 13.6 MB
Selected Resolution: 720p

Downloading....
69.38%
100.00%
Download Successful
Please go and watch the same under 'C:\Users\yousaf\youtube-video-downloader-pyscript/Downloads'....

C:\Users\yousaf\youtube-video-downloader-pyscript>dir Downloads
 Volume in drive C is Windows

 Directory of C:\Users\yousa\youtube-video-downloader-pyscript\Downloads

01/10/2022  08:49 AM        13,601,616 Thathaka Theithare Video Song  Hridayam  Pranav  Vineeth  Prithviraj  Hesham Visakh Merryland.mp4

C:\Users\yousa\youtube-video-downloader-pyscript>

ScreenShots

alt_txt alt_txt


Behind the code

import pytube  
from pytube import YouTube  
import os


current_path = os.getcwd()
if not os.path.exists("./Downloads"):
    os.makedirs("./Downloads")

video_url = input("Youtube URL: ")
    
def on_progress(stream, chunk, bytes_remaining):
    total_size = stream.filesize
    bytes_downloaded = total_size - bytes_remaining
    percentage_of_completion = bytes_downloaded / total_size * 100
    formated_percentage = "{:.2f}".format(percentage_of_completion)
    print(formated_percentage+"%")
        
def main():
    chunk_size = 1024
    video = yt.streams.get_highest_resolution()
    title = video.title
    print(f"\nFetching \"{video.title}\"..")
    print(f"Information: \n"
          f"Highest Resolution: {video.resolution}\n"
          f"Author: {yt.author}")
    print("Views: {:,}".format(yt.views))

    print("\nAvailable Formats: ")
    A=[]
    res=yt.streams.filter(progressive=True, file_extension='mp4')
    if res.filter(resolution="360p"):
        A.append("360p")

    if res.filter(resolution="480p"):
        A.append("480p")

    if res.filter(resolution="720p"):
        A.append("720p")

    if res.filter(resolution="1080p"):
        A.append("1080p")

    if res.filter(resolution="1440p"):
        A.append("1440p")
    print(A)
    
    format_res = input("Chosse one format would you like to download (eg:360p): ")
    if format_res.endswith("p"):
        if format_res in A:
            video = yt.streams.filter(res=format_res, file_extension = "mp4").first()
            print(f"\nInformation about the video format you had selected: \n"
                  f"File size: {round(video.filesize * 0.000001, 2)} MB\n"
                  f"Selected Resolution: {video.resolution}\n")
            print("Downloading....")
            yt.register_on_progress_callback(on_progress)
            yt.streams.filter(res=format_res, file_extension = "mp4").first().download("./downloads")
            print("Download Successful")
            print("Please go and watch same under '{}/Downloads'....".format(current_path))
        else:
            print("Choose a valid format from the available list mentioned above")
    else:
        format_res=format_res+"p"
        if format_res in A:
            video = yt.streams.filter(res=format_res, file_extension = 'mp4').first()
            print(f"\nInformation of the current video format: \n"
                  f"File size: {round(video.filesize * 0.000001, 2)} MB\n"
                  f"Selected Resolution: {video.resolution}\n")
            print("Downloading....")
            yt.register_on_progress_callback(on_progress)
            yt.streams.filter(res=format_res, file_extension = 'mp4').first().download("./downloads")
            print("Download Successful")
            print("Please go and watch the same under '{}/Downloads'....".format(current_path))
        else:
            print("Choose a valid format from the available list mentioned above")
            
if video_url.startswith("http"):
    yt=YouTube(video_url)
    main()
else:
    print("Please enter a valid URL.")

Conclusion

This is a simple python script and it's used for mp4 type video downloading from youtube.

⚙️ Connect with Me


Owner
Yousaf K Hamza
DevOps Engineer
Yousaf K Hamza
Download the resources of the Blue Archive easily!

blue-archive-bundle-downloader Download the resources of the Blue Archive easily! Known issue In Windows It works only if the console is "fullscreen"

Ryu juheon 7 Apr 08, 2022
A Fast as F*** Downloader

FAFD A Fast as F*** Downloader Github Usages You'll want to use a URL like this: https://github.com/RPowell-C/FAFD/raw/main/FAFD.py It's easier DONT F

1 Jan 19, 2022
Quickly, simply, and asynchronously download NFT's from an Opensea collection

iRightClick Quickly, simply, and asynchronously download NFT's from an Opensea collection. NOTICE This tool is not developed to encourage or facilitat

Setro 34 Dec 30, 2022
Source code of paper: "HRegNet: A Hierarchical Network for Efficient and Accurate Outdoor LiDAR Point Cloud Registration".

HRegNet: A Hierarchical Network for Efficient and Accurate Outdoor LiDAR Point Cloud Registration Environments The code mainly requires the following

Intelligent Sensing, Perception and Computing Group 3 Oct 06, 2022
Download Web-10K data by querying Bing Image Search

gpv2-web10k This repository contains the script to download images from the Web-10K dataset. The script takes in a list of queries, queries Bing Image

AI2 8 Sep 06, 2022
Downloads photos you saved from a specific profile.

instagram-download-saved A python script that downloads photos you saved from a specific profile. The only dependency is instaloader, an open-source p

Aviv 1 Dec 19, 2021
Download songs and playlists from Spotify for free!

spotify-to-mp3-converter You can basically understand the process with just this image but for clarity, these are the steps. Before using the exe down

2 Jan 25, 2022
A Unit3D Mass Release Downloader

Unit3DMassDL A Unit3D Mass Release Downloader. Currently supports Aither. Installation Ensure Python 3 is installed in your system. Run the following

2 Apr 11, 2022
You Can download any video/image in all social medias very easy and High Speed.

All-Downloader You Can download any video/image in all social medias very easy and High Speed. also you can easily download videos from web browsers s

Razor Kenway 14 Dec 16, 2022
A prometheus exporter for torrent downloader like qbittorrent/transmission/deluge

downloader-exporter A prometheus exporter for qBitorrent/Transmission/Deluge. Get metrics from multiple servers and offers them in a prometheus format

Lei Shi 41 Nov 18, 2022
apkizer is a mass downloader for android applications for all available versions.

apkizer apkizer collects all available versions of an Android application from apkpure.com Purpose Sometimes mobile applications can be useful to dig

Kamil Onur Özkaleli 41 Dec 16, 2022
Terminal based YouTube player and downloader

termitube NOTE: THIS REPOSITORY IS A FORK OF mps-youtube as mps-youtube has been unmaintained for almost a year now. Features Search and play audio/vi

Otis/Jacob Root 27 Dec 23, 2022
Persepolis Download Manager is a GUI for aria2.

Persepolis Download Manager Content About FAQ Screenshots Credits About Persepolis is a download manager & a GUI for Aria2. It's written in Python. Pe

Persepolis 5.6k Dec 31, 2022
A YouTube downloader app built with Django.

YouTube Downloader ⭐️ Star this project ⭐️ Requirements Python3+ Git Installation Install the dependencies and start the server. git clone https://git

Gabriel Tavares 26 Aug 19, 2022
S3 file download with Python and access with VBA

S3 file download with Python and access with VBA This simple project is using the following stacks: Python AWS S3 VBA/Excel A Bitcoin API With this st

Julio Cesar Scheidt 0 Dec 07, 2021
Tool To download Amazon 4k SDR HDR 1080, CDM IS Not Included

WV-AMZN-4K-RIPPER Tool To download Amazon 4k SDR HDR 1080, CDM IS Not Included For CDM You can Mail :- Denis Trunov 179 Dec 17, 2022

Download clips from youtube videos with a few clicks and a GUI!

YouClip v2.0.0 Table Of Contents: What Is YouClip Installation Usage Stuff To Fix Changelog What Is YouClip? ! IMPORTANT: The source files are a total

ador 2 Oct 05, 2021
Utility for downloading works from AO3 (Archive Of Our Own)

ao3d video preview A small graphical utility for batch downloading works from AO3 (Archive Of Our Own) Features Batch downloading works to supported f

flux 24 Dec 09, 2022
music downloader written in python. (Uses jiosaavn API)

music downloader written in python. (Uses jiosaavn API)

Rohn Chatterjee 35 Jul 20, 2022