Skip to main content

yt-transcript-fetcher | YouTube Transcript Fetcher

Run Tests PyPI - Version PyPI - Python Version PyPI - License PyPI - Downloads

A python package to fetch YouTube video transcripts.

Installation

Use the package manager pip to install yt-transcript-fetcher.

pip install yt-transcript-fetcher

Usage

Basic usage examples can be found in the examples directory.

Command Line Interface (CLI)

The package includes a basic command line interface for fetching transcripts. You can run the following command:

yt-transcript-fetcher list-languages <video_id>

This will list all available languages for the specified video ID.

yt-transcript-fetcher download -l <language_code> <video_id>

This will download the transcript for the specified video ID in the given language code and output it to standard output.

Python API

You can also use the package as a Python module. Here is a basic example:

from yt_transcript_fetcher import list_languages, get_transcript
video_id = "dQw4w9WgXcQ"  # Replace with your video ID
languages = list_languages(video_id)
print("Available languages:", languages)
transcript = get_transcript(video_id, language="en")
print(transcript.text)
for segment in transcript.segments:
    print(segment.start_ms, segment.end_ms, segment.text)

Backend and compatibility

The package discovers caption languages through YouTube's internal player endpoint and fetches transcript text through get_panel using protobuf parameters. It needs only Python and the existing package dependencies: no browser, JavaScript helper, cookies, API key, or caption-URL download.

The public functions, YouTubeTranscriptFetcher(session=None), model constructors, timing helpers, and CLI commands remain unchanged. Existing legacy response parsers and protobuf helpers remain available. A fetcher caches language discovery per video and respects caller-supplied sessions. If multiple tracks share a language code, the first matching track retains precedence.

YouTube's modern panel groups text differently, so segment counts, text grouping, and timing boundaries can differ from older transcripts. Times remain in milliseconds on start_ms/end_ms, and seconds on start/end. The parser checks the returned video and caption track and rejects incomplete or malformed timing data instead of returning an incorrectly labelled transcript.

This fix preserves the previous exception and retry behavior. Language discovery still maps HTTP failures to VideoNotFoundError, except JSON FAILED_PRECONDITION errors, which raise YouTubeAPIError. Transcript HTTP failures propagate as requests.HTTPError. Default sessions retain retries for HTTP 400, HTTP 429 and transient server failures, respecting Retry-After. Invalid modern panel selection or timing data raises YouTubeAPIError from yt_transcript_fetcher.exceptions. Revised transport exceptions and removal of HTTP 400 retries are reserved for a separate breaking release.

This uses an undocumented API and may need updates as YouTube changes. Successful requests do not establish the rate limit on a Discord bot's hosting network; cache transcripts and bound concurrency in the application. The protocol and verification evidence are recorded in research/README.md.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Metadata

Release files for yt-transcript-fetcher 1.2.2

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

Source distribution (sdist)

Source distribution for yt-transcript-fetcher 1.2.2
File Size Uploaded Provenance
yt_transcript_fetcher-1.2.2.tar.gz 120.3 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for yt-transcript-fetcher 1.2.2
File Interpreter ABI Platform
yt_transcript_fetcher-1.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 139.6 kB

Release files / yt_transcript_fetcher-1.2.2.tar.gz

Download URL yt_transcript_fetcher-1.2.2.tar.gz
Size 120.3 kB
Tags Source
SHA-256 checksum
How to use checksums
04ed98212fc6962c62d5878991d76c94c86c6b420a383218344d16ba93b86a4a
BLAKE2b-256 checksum
How to use checksums
aa75c84826f94cf9e1edc93bcfab86d4cf19181708ce59fcdba96c9a36451966
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Release files / yt_transcript_fetcher-1.2.2-py3-none-any.whl

Download URL yt_transcript_fetcher-1.2.2-py3-none-any.whl
Size 19.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0e22b3de81ebfcd12c1c5ed916694c110b18ab3fadb03a62ded18341f20f5e5e
BLAKE2b-256 checksum
How to use checksums
a5118387e965816cea5519f19db67cab10ef1150ff38d8839cbb1a23cadb5ef8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Security for yt-transcript-fetcher 1.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for yt_transcript_fetcher-1.2.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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