Skip to main content

utub3

YouTube is the world's most popular video hosting service, and you might come across a situation where you need a video download script. There is a utub3 for this purpose.

Utub3 is a lightweight, dependency-free Python library and command-line utility for downloading YouTube Videos.

Utub3 also simplifies piping by allowing you to set callback functions for various download events, such as progress or completion.

In addition, utub3 includes a command line utility that allows you to download videos directly from the terminal.

Quickstart

Installation

utub3 requires an installation of Python 3.6 or greater, as well as pip. (Pip is typically bundled with Python installations.)

To install from PyPI with pip:

$ python -m pip install utub3

Sometimes, the PyPI release becomes slightly outdated. To install from the source with pip:

$ python -m pip install git+https://github.com/pchchv/utub3

Using utub3 in a Python script

To download a video using the library in a script, you'll need to import the YouTube class from the library and pass an argument of the video URL. From there, you can access the streams and download them.

 >>> from utub3 import YouTube
 >>> YouTube('https://youtu.be/HxCcKzRAGWk').streams.first().download()
 >>> yt = YouTube('http://youtube.com/watch?v=HxCcKzRAGWk')
 >>> yt.streams
  ... .filter(progressive=True, file_extension='mp4')
  ... .order_by('resolution')
  ... .desc()
  ... .first()
  ... .download()

Using the command-line interface

Using the CLI is remarkably straightforward as well. To download a video at the highest progressive quality, you can use the following command:

$ utub3 https://youtube.com/watch?v=HxCcKzRAGWk

You can also do the same for a playlist:

$ utub3 https://www.youtube.com/watch?v=UP2XoGfhJ1Y&list=RDUP2XoGfhJ1Y&start_radio=1&t=3s

Metadata

Release files for utub3 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for utub3 1.0.0
File Size Uploaded
utub3-1.0.0.tar.gz 68.6 kB Details

Release files / utub3-1.0.0.tar.gz

Download URL utub3-1.0.0.tar.gz
Size 68.6 kB
Tags Source
SHA-256 checksum
How to use checksums
393f3ec704079ffef8f357114d45ff6dc8697de7d87b255b0bf2f4c665ed87ed
BLAKE2b-256 checksum
How to use checksums
ba08cb0ed44be54b0aefa4dc4d2a2c5b71e926467865ec671de7b76f9361c110
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file

0.2.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page