Skip to main content

Python 3 library for downloading YouTube Videos.

Project description

ytextract

ytextract is a genuine, lightweight Python library (and command-line utility) for downloading YouTube videos.

Description

YouTube is the most popular video-sharing platform in the world and as a hacker, you may encounter a situation where you want to script something to download videos. For this, I present to you: ytextract.

ytextract is a lightweight library written in Python. It has minimal dependencies and aims to be highly reliable.

ytextract also makes pipelining easy, allowing you to specify callback functions for different download events, such as on progress or on complete.

Furthermore, ytextract includes a command-line utility, allowing you to download videos right from the terminal.

Features

  • Support for both progressive & DASH streams
  • Easily register on_download_progress & on_download_complete callbacks
  • Command-line interface included
  • Caption track support
  • Outputs caption tracks to .srt format (SubRip Subtitle)
  • Ability to capture thumbnail URL
  • Extensively documented source code

Quickstart

Installation

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

To install from PyPI with pip:

pip install ytextract

Or install from source:

pip install -e .

Using the command-line interface

Use the ytextract command in a terminal to download videos, captions, or multiple videos from a list or channel.

Download a single video

To download a video at the highest progressive quality, you can use the following command:

ytextract https://youtube.com/watch?v=2lAe1cqCOXo

Download captions for a video

To download only captions for a video, use the --captions flag:

ytextract --captions https://youtube.com/watch?v=2lAe1cqCOXo

Download Videos from a list in a text file

To download multiple videos from a text file containing YouTube video URLs (one URL per line), use the --file flag:

ytextract --file videos.txt

Download Videos from a Channel, or multiple Channels

To download all videos from one or more YouTube channels, use the --channels flag followed by the channel usernames:

ytextract --channels officialalphablocks Numberblocks

Using ytextract in a Python script

To download a video using the library in a script, simply import ytextract and call the helper functions directly.

Download a single video

Set the url parameter to the YouTube video URL you wish to download.

import ytextract

ytextract.download(url="https://www.youtube.com/watch?v=VIDEO_ID")

Download captions for a video

Set the url parameter to the YouTube video URL you wish to download captions for.

import ytextract

ytextract.download_captions(url="https://www.youtube.com/watch?v=VIDEO_ID")

Download Videos from a list from videos.txt

You can change the filename argument to any text file containing YouTube video URLs (one URL per line).

import ytextract

ytextract.download_videos_from_list(filename="videos.txt")

Download Videos from a Channel, or multiple Channels

You can specify one or more channel usernames in the channels parameter to download all videos from those channels.

import ytextract

ytextract.download_videos_from_channels(channels=["officialalphablocks", "Numberblocks"])

License

This project is licensed under The Unlicense - see the LICENSE file for details.

Contributing

Feel free to open an issue or a pull request at https://github.com/Josh-XT/ytextract

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ytextract-0.0.1.tar.gz (56.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ytextract-0.0.1-py3-none-any.whl (49.6 kB view details)

Uploaded Python 3

File details

Details for the file ytextract-0.0.1.tar.gz.

File metadata

  • Download URL: ytextract-0.0.1.tar.gz
  • Upload date:
  • Size: 56.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for ytextract-0.0.1.tar.gz
Algorithm Hash digest
SHA256 a1153ca8c3f8455d4a7bb1c4406ad63689f04894f1244a87a764feb7c05b47b9
MD5 58376e78fffda042a2e45df08a807fe2
BLAKE2b-256 cdf05e80f9e08c912d72d36330a18e9436ff5a998d99e0d82210c298f7c0bf6f

See more details on using hashes here.

File details

Details for the file ytextract-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: ytextract-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 49.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for ytextract-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8a4dee68791f22fd6e737af17fab300746f4a2d9753d4664435948a0f8711954
MD5 20af610f52f61f6eee4638142b89b335
BLAKE2b-256 e963f535a7b4a4aa51f2d48c4067e4f1403020ea587514f1165281ea3663727d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page