Skip to main content

Youtube Closed Captions

Downloads the closed captions(subtitles) from Youtube videos

https://github.com/mkly/youtube-closed-captions/actions/workflows/ci.yml/badge.svg

Requirements

  • Currently requires Python >= 3.12

Install

pip install youtube-closed-captions

To Use

from ytcaptions import Download

video_id = 'jNQXAC9IVRw'
download = Download()
# Language is optional and default to "en"
# YouTube uses "en","fr" not "en-US", "fr-FR"
captions = download.get_captions(video_id, 'en')

Upgrading to 1.0.0

The Python package is now ytcaptions to avoid a conflict with the unrelated ytcc package. Update from ytcc.download import Download to from ytcaptions import Download. DownloadException is also exported from ytcaptions. Imports from ytcaptions.download and ytcaptions.storage remain available. The old ytcc import is removed.

The PyPI distribution name is youtube-closed-captions, and Python 3.12 or newer is required.

Development

Install the library and test dependencies from this directory:

pip install -e . -r requirements.txt

Run Tests

Note: Functional tests do download directly from Youtube

## All tests
pytest

## Or using unittest
python -m unittest discover

## Unit tests
python -m unittest discover test/unit

## Functional tests
python -m unittest discover test/functional

Prepare a release

Build and validate the release files locally:

pip install build twine
pytest test/unit
python -m build
python -m twine check --strict dist/youtube_closed_captions-1.0.0-py3-none-any.whl dist/youtube_closed_captions-1.0.0.tar.gz

These commands do not upload or publish the package. Live YouTube tests require network access and are skipped in CI because YouTube blocks datacenter IPs.

Metadata

Release files for youtube-closed-captions 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 youtube-closed-captions 1.0.0
File Size Uploaded
youtube_closed_captions-1.0.0.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for youtube-closed-captions 1.0.0
File Interpreter ABI Platform
youtube_closed_captions-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.1 kB

Release files / youtube_closed_captions-1.0.0.tar.gz

Download URL youtube_closed_captions-1.0.0.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a5be39555c5d7eb8f7b45e42e6fe1bd87326e41f1e8ee096fb978bd25760bf85
BLAKE2b-256 checksum
How to use checksums
27df08f4c268267f84281ca8d722c37a24886162ff2bdafdf9f48c591937a392
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / youtube_closed_captions-1.0.0-py3-none-any.whl

Download URL youtube_closed_captions-1.0.0-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ad0aff8e13a001a2761caf71c170ea185cea963fa3a99df78eb9591669a0ba84
BLAKE2b-256 checksum
How to use checksums
769fd7b78431fe93d55f0103ceb0730fd50ea00cdcf3608d771b3eb2d4bba67d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

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