Skip to main content

This is an python API which allows you to get the transcripts/subtitles for a given YouTube video. It also works for automatically generated subtitles and it does not require a headless browser, like other selenium based solutions do!

Project description

YouTube Transcript/Subtitle API (including automatically generated subtitles)

This is an python API which allows you to get the transcripts/subtitles for a given YouTube video. It also works for automatically generated subtitles and it does not require a headless browser, like other selenium based solutions do!

Install

It is recommended to install this module by using pip:

pip install youtube_transcript_api

If you want to use it from source, you'll have to install the dependencies manually:

pip install -r requirements.txt

How to use it

You could either integrate this module into an existing application, or just use it via an CLI

In code

To get a transcript for a given video you can do:

from youtube_transcript_api import YouTubeTranscriptApi

YouTubeTranscriptApi.get_transcript(video_id)

This will return a list of dictionaries looking somewhat like this:

[
    {
        'text': 'Hey there',
        'start': 7.58,
        'duration': 6.13
    },
    {
        'text': 'how are you',
        'start': 14.08,
        'duration': 7.58
    },
    # ...
]

To get transcripts for a list fo video ids you can call:

YouTubeTranscriptApi.get_transcripts(video_ids)

CLI

Execute the CLI script using the video ids as parameters and the results will be printed out to the command line:

youtube_transcript_api <first_video_id> <second_video_id> ...

If you would prefer to write it into a file or pipe it into another application, you can also output the results as json using the following line:

youtube_transcript_api --json <first_video_id> <second_video_id> ... > transcripts.json

Warning

This code uses an undocumented part of the YouTube API, which is called by the YouTube web-client. So there is no guarantee that it won't stop working tomorrow, if they change how things work. I will however do my best to make things working again as soon as possible if that happens. So if it stops working, let me know!

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

youtube_transcript_api-0.1.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

youtube_transcript_api-0.1.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file youtube_transcript_api-0.1.1.tar.gz.

File metadata

File hashes

Hashes for youtube_transcript_api-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6d484fd21b06d44603a0a7d8e5ad5c7d24f8438b21cfc960dd64d7d2d0a58399
MD5 67465b09a7b66cca11ccce185e70118c
BLAKE2b-256 279217ce1a35de1f3cf91e206869300c63f32a8c9042c468c7b70f456acbb8af

See more details on using hashes here.

File details

Details for the file youtube_transcript_api-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for youtube_transcript_api-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bd13f879ebd4b5342b30d433cb53279d3d59d99671dac4ec4e433bb74a44d64a
MD5 f52ed208730ee747905ea033d48f425d
BLAKE2b-256 9a414c9d45a2d3acde0938d515ee57af33e30656739601e72759623098e5eff3

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